<commit_before>//
//  InfrScheduleSortedAndExpanded.swift
//  RsyncOSXver30
//
//  Created by <NAME> on 22/09/2017.
//  Copyright © 2016 <NAME>. All rights reserved.
//  swiftlint More work to fix - 17 July 2017
//
//  swiftlint:disable syntactic_sugar

import Foundation
import Cocoa

class InfoScheduleSortedAndExpand: SetConfigurations {

    // Reference to main View
    private var sortedschedules: Array<NSDictionary>?
    private var scheduleInProgress: Bool = false

    // First job to execute.Job is first element in
    private func jobToExecute() -> NSDictionary? {
        guard self.sortedschedules != nil else { return nil}
        guard self.sortedschedules!.count > 0 else {return nil}
        return self.sortedschedules![0]
    }

    // Start timer or not in either main start window
    // Or in main execute window
    // seconds > 0 and <= 1800 every 1 second ( 0 - 30 minutes )
    // seconds > 1800 and <= 2 hours x 3600 <= 7200 every 60 seconds (minute) ( 30 minutes - 2 hours)
    // seconds > 7200 and <= 6 hours x 3600 = 21600 every 300 seconds (5 minues) ( 2 hours - 6 hours )
    // seconds > 21600 <= 24 x 3600 = 86,400 every 1/2 hour = 1800 seconds (30 minutes) ( 6 hours - 24 hours)
    func startTimerseconds () -> Double {
        if let start = self.jobToExecute() {
            let dateStart: Date = (start.value(forKey: "start") as? Date)!
            let seconds = Tools().timeDoubleSeconds(dateStart, enddate: nil)
            // 30 minutes every second
            if seconds > 0 && seconds <= 1800 {
                // Update every second
                return 1
                // 30 minutes and 2 hours every minute
            } else if seconds > 1800 && seconds <= 7200 {
                return 60
                // 2 and 6 hours every 5 minutes
            } else if seconds > 7200 && seconds <= 21600 {
                return 300
                // 7 and 24 hours every 30 minutes
            } else if seconds <= 86400 {
                // Dont start
                return 1800
            } else {
                // Dont start
                return 0
            }
        } else {
            if self.scheduleInProgress { return 1 } else { return 0 }
        }
    }

    // Info about next remote servers and paths for scheduled backup.
    func remoteServerAndPathNextTwoTasks() -> Array<String> {
        var dict1: NSDictionary?
        var dict2: NSDictionary?
        var array = Array<String>()
        guard self.sortedschedules != nil else { return [""] }
        if (self.sortedschedules!.count) > 1 {
            dict1 = self.sortedschedules![0]
            dict2 = self.sortedschedules![1]
        } else {
            if (self.sortedschedules!.count) > 0 {
                dict1 = self.sortedschedules![0]
            }
        }
        if dict1 != nil {
            let hiddenID1 = dict1!.value(forKey: "hiddenID") as? Int
            array.append(self.configurations!.getResourceConfiguration(hiddenID1!, resource: .offsiteServer))
            array.append(self.configurations!.getResourceConfiguration(hiddenID1!, resource: .localCatalog))
        }
        if dict2 != nil {
            let hiddenID2 = dict2?.value(forKey: "hiddenID") as? Int
            array.append(self.configurations!.getResourceConfiguration(hiddenID2!, resource: .offsiteServer))
            array.append(self.configurations!.getResourceConfiguration(hiddenID2!, resource: .localCatalog))
        }
        // Return either 0, 2 or 4 elements
        return array
    }

    // Info on first screen - two first scheduled backups.
    func whenIsNextTwoTasksString() {
        var firstbackup: String?
        var secondbackup: String?
        guard self.sortedschedules != nil else { return }
        // We are calculating the first object
        if (self.sortedschedules!.count) > 0 {
            if (self.sortedschedules!.count) > 0 {
                if let minutes1 = self.sortedschedules?[0] {
                    let date1: Date = (minutes1.value(forKey: "start") as? Date)!
                    firstbackup = Tools().timeString(date1, enddate: nil)
                }
            }
            if (self.sortedschedules!.count) > 1 {
                if let minutes2 = self.sortedschedules?[1] {
                    let date2: Date = (minutes2.value(forKey: "start") as? Date)!
                    secondbackup = Tools().timeString(date2, enddate: nil)
                }
            }
        }
    }

    // Returns when to next tasks ar due in seconds
    func whenIsNextTwoTasksDouble() {
        var firstbackup: Double = -1
        var secondbackup: Double = -1
        // We are calculating the first object
        guard self.sortedschedules != nil else { return }
        guard self.sortedschedules!.count > 0 else { return }
        if (self.sortedschedules!.count) > 0 {
            if let minutes1 = self.sortedschedules?[0] {
                let date1: Date = (minutes1.value(forKey: "start") as? Date)!
                firstbackup = Tools().timeDoubleMinutes(date1, enddate: nil)
            }
        }
        if (self.sortedschedules!.count) > 1 {
            if let minutes2 = self.sortedschedules?[1] {
                let date2: Date = (minutes2.value(forKey: "start") as? Date)!
                secondbackup = Tools().timeDoubleMinutes(date2, enddate: nil)
            }
        }
    }

    init (sortedandexpanded: ScheduleSortedAndExpand?) {
        guard sortedandexpanded != nil else { return }
        self.sortedschedules = sortedandexpanded!.getsortedAndExpandedScheduleData()
    }
}<commit_msg>commented out some functions not in use<commit_after>//
//  InfrScheduleSortedAndExpanded.swift
//  RsyncOSXver30
//
//  Created by <NAME> on 22/09/2017.
//  Copyright © 2016 <NAME>. All rights reserved.
//  swiftlint More work to fix - 17 July 2017
//
//  swiftlint:disable syntactic_sugar

import Foundation
import Cocoa

class InfoScheduleSortedAndExpand: SetConfigurations {

    // Reference to main View
    private var sortedschedules: Array<NSDictionary>?
    private var scheduleInProgress: Bool = false

    // First job to execute.Job is first element in
    private func jobToExecute() -> NSDictionary? {
        guard self.sortedschedules != nil else { return nil}
        guard self.sortedschedules!.count > 0 else {return nil}
        return self.sortedschedules![0]
    }

    // Start timer or not in either main start window
    // Or in main execute window
    // seconds > 0 and <= 1800 every 1 second ( 0 - 30 minutes )
    // seconds > 1800 and <= 2 hours x 3600 <= 7200 every 60 seconds (minute) ( 30 minutes - 2 hours)
    // seconds > 7200 and <= 6 hours x 3600 = 21600 every 300 seconds (5 minues) ( 2 hours - 6 hours )
    // seconds > 21600 <= 24 x 3600 = 86,400 every 1/2 hour = 1800 seconds (30 minutes) ( 6 hours - 24 hours)
    func startTimerseconds () -> Double {
        if let start = self.jobToExecute() {
            let dateStart: Date = (start.value(forKey: "start") as? Date)!
            let seconds = Tools().timeDoubleSeconds(dateStart, enddate: nil)
            // 30 minutes every second
            if seconds > 0 && seconds <= 1800 {
                // Update every second
                return 1
                // 30 minutes and 2 hours every minute
            } else if seconds > 1800 && seconds <= 7200 {
                return 60
                // 2 and 6 hours every 5 minutes
            } else if seconds > 7200 && seconds <= 21600 {
                return 300
                // 7 and 24 hours every 30 minutes
            } else if seconds <= 86400 {
                // Dont start
                return 1800
            } else {
                // Dont start
                return 0
            }
        } else {
            if self.scheduleInProgress { return 1 } else { return 0 }
        }
    }

    // Info about next remote servers and paths for scheduled backup.
    func remoteServerAndPathNextTwoTasks() -> Array<String> {
        var dict1: NSDictionary?
        var dict2: NSDictionary?
        var array = Array<String>()
        guard self.sortedschedules != nil else { return [""] }
        if (self.sortedschedules!.count) > 1 {
            dict1 = self.sortedschedules![0]
            dict2 = self.sortedschedules![1]
        } else {
            if (self.sortedschedules!.count) > 0 {
                dict1 = self.sortedschedules![0]
            }
        }
        if dict1 != nil {
            let hiddenID1 = dict1!.value(forKey: "hiddenID") as? Int
            array.append(self.configurations!.getResourceConfiguration(hiddenID1!, resource: .offsiteServer))
            array.append(self.configurations!.getResourceConfiguration(hiddenID1!, resource: .localCatalog))
        }
        if dict2 != nil {
            let hiddenID2 = dict2?.value(forKey: "hiddenID") as? Int
            array.append(self.configurations!.getResourceConfiguration(hiddenID2!, resource: .offsiteServer))
            array.append(self.configurations!.getResourceConfiguration(hiddenID2!, resource: .localCatalog))
        }
        // Return either 0, 2 or 4 elements
        return array
    }
/*
    // Info on first screen - two first scheduled backups.
    func whenIsNextTwoTasksString() {
        var firstbackup: String?
        var secondbackup: String?
        guard self.sortedschedules != nil else { return }
        // We are calculating the first object
        if (self.sortedschedules!.count) > 0 {
            if (self.sortedschedules!.count) > 0 {
                if let minutes1 = self.sortedschedules?[0] {
                    let date1: Date = (minutes1.value(forKey: "start") as? Date)!
                    firstbackup = Tools().timeString(date1, enddate: nil)
                }
            }
            if (self.sortedschedules!.count) > 1 {
                if let minutes2 = self.sortedschedules?[1] {
                    let date2: Date = (minutes2.value(forKey: "start") as? Date)!
                    secondbackup = Tools().timeString(date2, enddate: nil)
                }
            }
        }
    }

    // Returns when to next tasks ar due in seconds
    func whenIsNextTwoTasksDouble() {
        var firstbackup: Double = -1
        var secondbackup: Double = -1
        // We are calculating the first object
        guard self.sortedschedules != nil else { return }
        guard self.sortedschedules!.count > 0 else { return }
        if (self.sortedschedules!.count) > 0 {
            if let minutes1 = self.sortedschedules?[0] {
                let date1: Date = (minutes1.value(forKey: "start") as? Date)!
                firstbackup = Tools().timeDoubleMinutes(date1, enddate: nil)
            }
        }
        if (self.sortedschedules!.count) > 1 {
            if let minutes2 = self.sortedschedules?[1] {
                let date2: Date = (minutes2.value(forKey: "start") as? Date)!
                secondbackup = Tools().timeDoubleMinutes(date2, enddate: nil)
            }
        }
    }
*/
    init (sortedandexpanded: ScheduleSortedAndExpand?) {
        guard sortedandexpanded != nil else { return }
        self.sortedschedules = sortedandexpanded!.getsortedAndExpandedScheduleData()
    }
}
{'fraction_non_alphanumeric': 0.09799713876967096, 'fraction_numerical': 0.0357653791130186, 'mean_word_length': 1.901426718547341, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 51, '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': '6710458', 'n_tokens_mistral': 3406, 'n_tokens_neox': 2996, 'n_words': 930}