<commit_before>//
//  ObservedAlertsVC.swift
//  zmon
//
//  Created by <NAME> on 22/04/16.
//  Copyright © 2016 Zalando Tech. All rights reserved.
//

import UIKit

class ObservedAlertsVC: BaseVC {

    @IBOutlet weak var tableView: UITableView!
    
    let alertService = ZmonAlertsService()
    var observedAlerts: [ZmonServiceResponse.Alert] = []
    var remoteAlerts: [ZmonServiceResponse.Alert] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        configureNavigationItem()
        configureTableView()
    }
    
    func fetchRemoteAlerts() {
        
        alertService.listRemoteObservableAlertsWithCompletion { alerts in
            
            if let alerts = alerts {
                
                log.info("Successfully fetched \(alerts.count) alerts!")
                
                self.remoteAlerts = alerts
                self.fetchUserObservedAlerts()
                
            } else {
                log.error("Failed to fetch remote alerts")
            }
        }
    }
    
    func fetchUserObservedAlerts() {
        
        alertService.listUserObservedAlertsWithCompletion { alertIDs in
            
            if let alertIDs = alertIDs {
                
                log.info("Successfully fetched user observed alerts (\(alertIDs.count))")

                self.observedAlerts = self.remoteAlerts.filter({ (alert) -> Bool in<commit_msg>Progress HUD is shown when listing observed alerts<commit_after>//
//  ObservedAlertsVC.swift
//  zmon
//
//  Created by <NAME> on 22/04/16.
//  Copyright © 2016 Zalando Tech. All rights reserved.
//

import UIKit
import SVProgressHUD

class ObservedAlertsVC: BaseVC {

    @IBOutlet weak var tableView: UITableView!
    
    let alertService = ZmonAlertsService()
    var observedAlerts: [ZmonServiceResponse.Alert] = []
    var remoteAlerts: [ZmonServiceResponse.Alert] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        configureNavigationItem()
        configureTableView()
    }
    
    func fetchRemoteAlerts() {
        
        SVProgressHUD.show()
        
        alertService.listRemoteObservableAlertsWithCompletion { alerts in
            
            if let alerts = alerts {
                
                log.info("Successfully fetched \(alerts.count) alerts!")
                
                self.remoteAlerts = alerts
                self.fetchUserObservedAlerts()
                
            } else {
                
                SVProgressHUD.dismiss()
                log.error("Failed to fetch remote alerts")
            }
        }
    }
    
    func fetchUserObservedAlerts() {
        
        alertService.listUserObservedAlertsWithCompletion { alertIDs in
            
            SVProgressHUD.dismiss()
            
            if let alertIDs = alertIDs {
                
                log.info("Successfully fetched user observed alerts (\(alertIDs.count))")

                self.observedAlerts = self.remoteAlerts.filter({ (alert) -> Bool in
{'fraction_non_alphanumeric': 0.08162590879048248, 'fraction_numerical': 0.006609385327164574, 'mean_word_length': 1.7050938337801609, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4319130', 'n_tokens_mistral': 846, 'n_tokens_neox': 783, 'n_words': 177}