<commit_before>//
//  Notofication.swift
//  PairProgrammingTimer
//
//  Created by <NAME> on 17/03/2017.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation
import UserNotifications


protocol Notifications {
    func register()
    func cancelPending()
}

// ToDo: empty implementation when notifications are disabled


class LocalNotifications: Notifications {
    
    private let timeInterval: Double
    
    init(timeInterval: Double) {
        self.timeInterval = timeInterval
    }
 
    func register() {
        
        let center = UNUserNotificationCenter.current()
        
        let content = UNMutableNotificationContent()
        content.title = "PairProgrammingTimer"
        content.body = "Session timer expired!"
        content.sound = UNNotificationSound.default()

        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: self.timeInterval, repeats: false)
        
        let identifier = "TimeExpired"
        let request = UNNotificationRequest(identifier: identifier,
                                            content: content, trigger: trigger)
        center.add(request, withCompletionHandler: { (error) in
            if let error = error {
                NSLog("Error creating notification: \(error)")
                return;
            }
            
            NSLog("Local notification added")
        })
        
    }
    
    func cancelPending() {
        
        let center = UNUserNotificationCenter.current()
        
        center.removeAllPendingNotificationRequests()
    }
}<commit_msg>NSLogging for notifications<commit_after>//
//  Notofication.swift
//  PairProgrammingTimer
//
//  Created by <NAME> on 17/03/2017.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation
import UserNotifications


protocol Notifications {
    func register()
    func cancelPending()
}

class LocalNotifications: Notifications {
    
    private let timeInterval: Double
    
    init(timeInterval: Double) {
        self.timeInterval = timeInterval
    }
 
    func register() {
        
        let center = UNUserNotificationCenter.current()
        
        let content = UNMutableNotificationContent()
        content.title = "PairProgrammingTimer"
        content.body = "Session timer expired!"
        content.sound = UNNotificationSound.default()

        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: self.timeInterval, repeats: false)
        
        let identifier = "TimeExpired"
        let request = UNNotificationRequest(identifier: identifier,
                                            content: content, trigger: trigger)
        center.add(request, withCompletionHandler: { (error) in
            if let error = error {
                NSLog("Error creating notification: \(error)")
                return;
            }
            
            NSLog("Local notification added")
        })
        
    }
    
    func cancelPending() {
        
        let center = UNUserNotificationCenter.current()
        
        center.removeAllPendingNotificationRequests()
        
        NSLog("Eventually pending local notifications removed")
    }
}
{'fraction_non_alphanumeric': 0.08026440037771483, 'fraction_numerical': 0.007554296506137866, 'mean_word_length': 2.082444228903977, 'pattern_counts': {'":': 0, '<': 7, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2964976', 'n_tokens_mistral': 789, 'n_tokens_neox': 748, 'n_words': 196}