<commit_before>//
//  Build.swift
//  JenkinsiOS
//
//  Created by Robert on 23.09.16.
//  Copyright © 2016 MobiLab Solutions. All rights reserved.
//

import Foundation

class Build: CustomDebugStringConvertible{
    
    var number: Int
    var url: URL
    
    
    //TODO: Add actions/causes
    var actions: Actions?
    
    var building: Bool?
    var description: String?
    
    var displayName: String?
    var fullDisplayName: String?
    
    var id: String?
    var result: String?
    var builtOn: String?
    
    var duration: TimeInterval?
    var estimatedDuration: TimeInterval?
    
    var consoleOutputUrl: URL{
        get{
            return url.appendingPathComponent("/logText/progressiveHtml?start=0")
        }
    }
    
    init?(json: [String: AnyObject], minimalVersion: Bool = false){
        guard let number = json["number"] as? Int, let urlString = json["url"] as? String, let url = URL(string: urlString)
            else { return nil }
        
        self.number = number
        self.url = url
        
        if !minimalVersion{
            addAdditionalFields(from: json)
        }
    }
    
    /// Add values for fields in the full job category
    ///
    /// - parameter json: The JSON parsed data from which to get the values for the additional fields
    func addAdditionalFields(from json: [String: AnyObject]){
        
        if let actionsJson = json["actions"] as? [[String: AnyObject]]{
            actions = Actions(json: actionsJson)
        }
        
        building = json["building"] as? Bool
        description = json["description"] as? String
        displayName = json["displayName"] as? String
        fullDisplayName = json["fullDisplayName"] as? String
        id = json["id"] as? String
        result = json["result"] as? String
        builtOn = json["builtOn"] as? String
        
        duration = json["duration"] as? TimeInterval
        estimatedDuration = json["estimatedDuration"] as? TimeInterval
    }
    
    var debugDescription: String{
        return "Build #\(number) at \(url)"
    }
}<commit_msg>Add changes to build<commit_after>//
//  Build.swift
//  JenkinsiOS
//
//  Created by Robert on 23.09.16.
//  Copyright © 2016 MobiLab Solutions. All rights reserved.
//

import Foundation

class Build: CustomDebugStringConvertible{
    
    var number: Int
    var url: URL
    
    
    //TODO: Add actions/causes
    var actions: Actions?
    
    var building: Bool?
    var description: String?
    
    var displayName: String?
    var fullDisplayName: String?
    
    var id: String?
    var result: String?
    var builtOn: String?
    
    var duration: TimeInterval?
    var estimatedDuration: TimeInterval?
    
    var changeSet: ChangeSet?
    
    var consoleOutputUrl: URL{
        get{
            var components = URLComponents(url: url.appendingPathComponent("/logText/progressiveHtml"), resolvingAgainstBaseURL: true)
            components?.queryItems = [
                URLQueryItem(name: "start", value: "0")
            ]
            return components?.url ?? url
        }
    }
    
    init?(json: [String: AnyObject], minimalVersion: Bool = false){
        guard let number = json["number"] as? Int, let urlString = json["url"] as? String, let url = URL(string: urlString)
            else { return nil }
        
        self.number = number
        self.url = url
        
        if !minimalVersion{
            addAdditionalFields(from: json)
        }
    }
    
    /// Add values for fields in the full job category
    ///
    /// - parameter json: The JSON parsed data from which to get the values for the additional fields
    func addAdditionalFields(from json: [String: AnyObject]){
        
        if let actionsJson = json["actions"] as? [[String: AnyObject]]{
            actions = Actions(json: actionsJson)
        }
        
        building = json["building"] as? Bool
        description = json["description"] as? String
        displayName = json["displayName"] as? String
        fullDisplayName = json["fullDisplayName"] as? String
        id = json["id"] as? String
        result = json["result"] as? String
        builtOn = json["builtOn"] as? String
        
        duration = json["duration"] as? TimeInterval
        estimatedDuration = json["estimatedDuration"] as? TimeInterval
        
        if let changeSetJson = json["changeSet"] as? [String: AnyObject]{
            changeSet = ChangeSet(json: changeSetJson)
        }
    }
    
    var debugDescription: String{
        return "Build #\(number) at \(url)"
    }
}
{'fraction_non_alphanumeric': 0.10074300699300699, 'fraction_numerical': 0.004807692307692308, 'mean_word_length': 2.1413864104323954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5965182', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1237, 'n_words': 392}