<commit_before>//
//  SiteTableViewswift
//  Nightscouter
//
//  Created by <NAME> on 6/16/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import NightscouterKit

class SiteNSNowTableViewCell: UITableViewCell {
    
    @IBOutlet weak var siteLastReadingHeader: UILabel!
    @IBOutlet weak var siteLastReadingLabel: UILabel!
    
    @IBOutlet weak var siteBatteryHeader: UILabel!
    @IBOutlet weak var siteBatteryLabel: UILabel!
    
    @IBOutlet weak var siteRawHeader: UILabel!
    @IBOutlet weak var siteRawLabel: UILabel!
    
    @IBOutlet weak var siteNameLabel: UILabel!
    
     @IBOutlet weak var siteColorBlockView: UIView!
    // @IBOutlet weak var siteCompassControl: CompassControl!
    
    @IBOutlet weak var siteSgvLabel: UILabel!
    @IBOutlet weak var siteDirectionLabel: UILabel!
    
    // @IBOutlet weak var siteDeltaHeader: UILabel!
    // @IBOutlet weak var siteDeltaLabel: UILabel!
    
    // @IBOutlet weak var siteUrlLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.backgroundColor = UIColor.clearColor()
    }
    
    func configureCell(site: Site) {
        
        // siteUrlLabel.text = site.url.host
        
        let defaultTextColor = Theme.Color.labelTextColor
        
        if let configuration = site.configuration {
            
            siteNameLabel.text = configuration.displayName
            
            var units: Units = configuration.displayUnits
            
            if let watchEntry = site.watchEntry {
                // Configure compass control
                // siteCompassControl.configureWith(site)
                
                // Battery label
                siteBatteryLabel.text = watchEntry.batteryString
                siteBatteryLabel.textColor = colorForDesiredColorState(watchEntry.batteryColorState)
                
                // Last reading label
                siteLastReadingLabel.text = watchEntry.dateTimeAgoString
                
                if let sgvValue = watchEntry.sgv {
                    let color = colorForDesiredColorState(site.configuration!.boundedColorForGlucoseValue(sgvValue.sgv))
                    siteColorBlockView.backgroundColor = color
                    siteSgvLabel.text = "\(sgvValue.sgvString) \(sgvValue.direction.emojiForDirection)"
                    siteSgvLabel.textColor = color
                    
                    siteDirectionLabel.text = "\(watchEntry.bgdelta.formattedForBGDelta) \(units.description)"
                    siteDirectionLabel.textColor = color
                    
                    if let enabledOptions = configuration.enabledOptions {
                        let rawEnabled =  contains(enabledOptions, EnabledOptions.rawbg)
                        if rawEnabled {
                            if let rawValue = watchEntry.raw {
                                let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
                                
                                let numberFormatter = NSNumberFormatter()
                                var raw = rawValue
                                if configuration.displayUnits == .Mmol {
                                    raw = rawValue.toMmol
                                    numberFormatter.numberStyle = .DecimalStyle
                                    numberFormatter.minimumFractionDigits = 1
                                    numberFormatter.maximumFractionDigits = 1
                                    numberFormatter.secondaryGroupingSize = 1
                                }
                                
                                siteRawLabel?.textColor = color
                                siteRawLabel.text = "\(numberFormatter.stringFromNumber(raw)!) : \(sgvValue.noise)"
                            }
                        } else {
                            siteRawHeader.hidden = true
                            siteRawLabel.hidden = true
                        }
                    }

                    let timeAgo = watchEntry.date.timeIntervalSinceNow
                    let isStaleData = configuration.isDataStaleWith(interval: timeAgo)
                    // siteCompassControl.shouldLookStale(look: isStaleData.warn)
                    
                    if isStaleData.warn {
                        siteBatteryLabel?.text = "---%"
                        siteBatteryLabel?.textColor = defaultTextColor
                        siteRawLabel?.text = "--- : ---"
                        siteRawLabel?.textColor = defaultTextColor
                        siteLastReadingLabel?.textColor = NSAssetKit.predefinedWarningColor
                        siteColorBlockView.backgroundColor = colorForDesiredColorState(DesiredColorState.Neutral)
                        
                        siteSgvLabel.text = "---"
                        siteSgvLabel.textColor = colorForDesiredColorState(.Neutral)
                        
                        siteDirectionLabel.text = "----"
                        siteDirectionLabel.textColor = colorForDesiredColorState(.Neutral)
                    }
                    
                    if isStaleData.urgent{
                        siteLastReadingLabel?.textColor = NSAssetKit.predefinedAlertColor
                    }
                    
                } else {
                    #if DEBUG
                        println("No SGV was found in the watch")
                    #endif
                }
                
            } else {
                // No watch was there...
                #if DEBUG
                    println("No watch data was found...")
                #endif
            }
        } else {
            #if DEBUG
                println("No site current configuration was found for \(site.url)")
            #endif
        }
    }
    
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
    }
    
    override func prepareForReuse() {
        super.prepareForReuse()
        
        siteNameLabel.text = nil
        siteBatteryLabel.text = nil
        siteRawLabel.text = nil
        siteLastReadingLabel.text = nil
        // siteCompassControl.shouldLookStale(look: true)
         siteColorBlockView.backgroundColor = colorForDesiredColorState(DesiredColorState.Neutral)
        
        siteSgvLabel.text = nil
        siteSgvLabel.textColor = Theme.Color.labelTextColor
        
        siteDirectionLabel.text = nil
        siteDirectionLabel.textColor = Theme.Color.labelTextColor
        
        siteLastReadingLabel.text = Constants.LocalizedString.tableViewCellLoading.localized
        siteLastReadingLabel.textColor = Theme.Color.labelTextColor
        
        siteRawHeader.hidden = false
        siteRawLabel.hidden = false
        siteRawLabel.textColor = Theme.Color.labelTextColor
    }
}
<commit_msg>forgot to update today widget<commit_after>//
//  SiteTableViewswift
//  Nightscouter
//
//  Created by <NAME> on 6/16/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import NightscouterKit

class SiteNSNowTableViewCell: UITableViewCell {
    
    @IBOutlet weak var siteLastReadingHeader: UILabel!
    @IBOutlet weak var siteLastReadingLabel: UILabel!
    
    @IBOutlet weak var siteBatteryHeader: UILabel!
    @IBOutlet weak var siteBatteryLabel: UILabel!
    
    @IBOutlet weak var siteRawHeader: UILabel!
    @IBOutlet weak var siteRawLabel: UILabel!
    
    @IBOutlet weak var siteNameLabel: UILabel!
    
     @IBOutlet weak var siteColorBlockView: UIView!
    // @IBOutlet weak var siteCompassControl: CompassControl!
    
    @IBOutlet weak var siteSgvLabel: UILabel!
    @IBOutlet weak var siteDirectionLabel: UILabel!
    
    // @IBOutlet weak var siteDeltaHeader: UILabel!
    // @IBOutlet weak var siteDeltaLabel: UILabel!
    
    // @IBOutlet weak var siteUrlLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.backgroundColor = UIColor.clearColor()
    }
    
    func configureCell(site: Site) {
        
        // siteUrlLabel.text = site.url.host
        
        let defaultTextColor = Theme.Color.labelTextColor
        
        if let configuration = site.configuration {
            
            siteNameLabel.text = configuration.displayName
            
            var units: Units = configuration.displayUnits
            
            if let watchEntry = site.watchEntry {
                // Configure compass control
                // siteCompassControl.configureWith(site)
                
                // Battery label
                siteBatteryLabel.text = watchEntry.batteryString
                siteBatteryLabel.textColor = colorForDesiredColorState(watchEntry.batteryColorState)
                
                // Last reading label
                siteLastReadingLabel.text = watchEntry.dateTimeAgoString
                
                if let sgvValue = watchEntry.sgv {
                
                    var boundedColor = configuration.boundedColorForGlucoseValue(sgvValue.sgv)
                    if units == .Mmol {
                        boundedColor = configuration.boundedColorForGlucoseValue(sgvValue.sgv.toMgdl)
                    }
                    let color = colorForDesiredColorState(boundedColor)
                    
                    siteColorBlockView.backgroundColor = color
                    
                    siteSgvLabel.text = "\(sgvValue.sgvString) \(sgvValue.direction.emojiForDirection)"
                    siteSgvLabel.textColor = color
                    
                    siteDirectionLabel.text = "\(watchEntry.bgdelta.formattedForBGDelta) \(units.description)"
                    siteDirectionLabel.textColor = color

                    
                    if let enabledOptions = configuration.enabledOptions {
                        let rawEnabled =  contains(enabledOptions, EnabledOptions.rawbg)
                        if rawEnabled {
                            if let rawValue = watchEntry.raw {
                                let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
                                
                                var raw = "\(rawValue.formattedForMgdl)"
                                if configuration.displayUnits == .Mmol {
                                    raw = rawValue.formattedForMmol
                                }
                                
                                siteRawLabel?.textColor = color
                                siteRawLabel.text = "\(raw) : \(sgvValue.noise)"
                            }
                        } else {
                            siteRawHeader.hidden = true
                            siteRawLabel.hidden = true
                        }
                    }

                    let timeAgo = watchEntry.date.timeIntervalSinceNow
                    let isStaleData = configuration.isDataStaleWith(interval: timeAgo)
                    // siteCompassControl.shouldLookStale(look: isStaleData.warn)
                    
                    if isStaleData.warn {
                        siteBatteryLabel?.text = "---%"
                        siteBatteryLabel?.textColor = defaultTextColor
                        siteRawLabel?.text = "--- : ---"
                        siteRawLabel?.textColor = defaultTextColor
                        siteLastReadingLabel?.textColor = NSAssetKit.predefinedWarningColor
                        siteColorBlockView.backgroundColor = colorForDesiredColorState(DesiredColorState.Neutral)
                        
                        siteSgvLabel.text = "---"
                        siteSgvLabel.textColor = colorForDesiredColorState(.Neutral)
                        
                        siteDirectionLabel.text = "----"
                        siteDirectionLabel.textColor = colorForDesiredColorState(.Neutral)
                    }
                    
                    if isStaleData.urgent{
                        siteLastReadingLabel?.textColor = NSAssetKit.predefinedAlertColor
                    }
                    
                } else {
                    #if DEBUG
                        println("No SGV was found in the watch")
                    #endif
                }
                
            } else {
                // No watch was there...
                #if DEBUG
                    println("No watch data was found...")
                #endif
            }
        } else {
            #if DEBUG
                println("No site current configuration was found for \(site.url)")
            #endif
        }
    }
    
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
    }
    
    override func prepareForReuse() {
        super.prepareForReuse()
        
        siteNameLabel.text = nil
        siteBatteryLabel.text = nil
        siteRawLabel.text = nil
        siteLastReadingLabel.text = nil
        // siteCompassControl.shouldLookStale(look: true)
         siteColorBlockView.backgroundColor = colorForDesiredColorState(DesiredColorState.Neutral)
        
        siteSgvLabel.text = nil
        siteSgvLabel.textColor = Theme.Color.labelTextColor
        
        siteDirectionLabel.text = nil
        siteDirectionLabel.textColor = Theme.Color.labelTextColor
        
        siteLastReadingLabel.text = Constants.LocalizedString.tableViewCellLoading.localized
        siteLastReadingLabel.textColor = Theme.Color.labelTextColor
        
        siteRawHeader.hidden = false
        siteRawLabel.hidden = false
        siteRawLabel.textColor = Theme.Color.labelTextColor
    }
}

{'fraction_non_alphanumeric': 0.06388908740084327, 'fraction_numerical': 0.0015007503751875938, 'mean_word_length': 1.378718340982492, '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': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2642157', 'n_tokens_mistral': 3482, 'n_tokens_neox': 3259, 'n_words': 639}