<commit_before>//
//  Session.swift
//  WWDC
//
//  Created by <NAME> on 06/06/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation
import RealmSwift

class Session: Object {
    
    dynamic var uniqueId = ""
    dynamic var id = 0
    dynamic var year = 0
    dynamic var date = ""
    dynamic var track = ""
    dynamic var focus = ""
    dynamic var title = ""
    dynamic var summary = ""
    dynamic var videoURL = ""
    dynamic var hdVideoURL = ""
    dynamic var slidesURL = ""
    dynamic var shelfImageURL = ""
    dynamic var progress = 0.0
    dynamic var currentPosition: Double = 0.0
    dynamic var favorite = false
    dynamic var transcript: Transcript?
    dynamic var slidesPDFData = NSData()
    dynamic var downloaded = false
    
    var isScheduled: Bool {
        guard let schedule = schedule else { return false }
        
        return schedule.endsAt.isGreaterThanOrEqualTo(NSDate())
    }
    
    var schedule: ScheduledSession? {
        guard let realm = realm else { return nil }
        
        return realm.objectForPrimaryKey(ScheduledSession.self, key: uniqueId)
    }
    
    var event: String {
        if id > 10000 {
            return "Apple TV Tech Talks"
        } else {
            return "WWDC"
        }
    }
    
    var isExtra: Bool {
        return event != "WWDC"
    }
    
    override static func primaryKey() -> String? {
        return "uniqueId"
    }
    
    override static func indexedProperties() -> [String] {
        return ["title"]
    }
    
    var shareURL: String {
        get {
            return "wwdc://\(year)/\(id)"
        }
    }<commit_msg>Validating session and schedule on schedule getters<commit_after>//
//  Session.swift
//  WWDC
//
//  Created by <NAME> on 06/06/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation
import RealmSwift

class Session: Object {
    
    dynamic var uniqueId = ""
    dynamic var id = 0
    dynamic var year = 0
    dynamic var date = ""
    dynamic var track = ""
    dynamic var focus = ""
    dynamic var title = ""
    dynamic var summary = ""
    dynamic var videoURL = ""
    dynamic var hdVideoURL = ""
    dynamic var slidesURL = ""
    dynamic var shelfImageURL = ""
    dynamic var progress = 0.0
    dynamic var currentPosition: Double = 0.0
    dynamic var favorite = false
    dynamic var transcript: Transcript?
    dynamic var slidesPDFData = NSData()
    dynamic var downloaded = false
    
    var isScheduled: Bool {
        guard let schedule = schedule where !schedule.invalidated else { return false }
        
        return schedule.endsAt.isGreaterThanOrEqualTo(NSDate())
    }
    
    var schedule: ScheduledSession? {
        guard let realm = realm where !invalidated else { return nil }
        
        return realm.objectForPrimaryKey(ScheduledSession.self, key: uniqueId)
    }
    
    var event: String {
        if id > 10000 {
            return "Apple TV Tech Talks"
        } else {
            return "WWDC"
        }
    }
    
    var isExtra: Bool {
        return event != "WWDC"
    }
    
    override static func primaryKey() -> String? {
        return "uniqueId"
    }
    
    override static func indexedProperties() -> [String] {
        return ["title"]
    }
    
    var shareURL: String {
        get {
            return "wwdc://\(year)/\(id)"
        }
    }
{'fraction_non_alphanumeric': 0.09311262193319539, 'fraction_numerical': 0.012415016257759386, 'mean_word_length': 1.9324090121317157, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4508491', 'n_tokens_mistral': 995, 'n_tokens_neox': 939, 'n_words': 312}