<commit_before>import UIKit

enum ReserveStatus {
    case NoReserve
    case ReserveNotMet(Int)
    case ReserveMet
}

struct SaleNumberFormatter {
    static let dollarFormatter = createDollarFormatter()
}

class SaleArtwork: JSONAble {

    let id: String
    let artwork: Artwork

    var auction: Sale?

    // The bidder is given from JSON if user is registered
    let bidder: Bidder?

    var saleHighestBid: Bid?
    var bidCount: Int?

    var userBidderPosition: BidderPosition?
    var positions: [String]?

    dynamic var openingBidCents: NSNumber?
    var minimumNextBidCents: Int?
    
    var highestBidCents: Int?
    var lowEstimateCents: Int?
    var highEstimateCents: Int?

    init(id: String, artwork: Artwork) {
        self.id = id
        self.artwork = artwork
    }

    override class func fromJSON(json: [String: AnyObject]) -> JSONAble {
        let json = JSON(object: json)

        let id = json["id"].stringValue
        let artworkDict = json["artwork"].object as [String: AnyObject]
        let artwork = Artwork.fromJSON(artworkDict) as Artwork

        let sale = SaleArtwork(id: id, artwork: artwork) as SaleArtwork

        if let highestBidDict = json["highest_bid"].object as? [String: AnyObject] {
            sale.saleHighestBid = Bid.fromJSON(highestBidDict) as? Bid
        }
        
        sale.openingBidCents = json["opening_bid_cents"].integer
        sale.minimumNextBidCents = json["minimum_next_bid_cents"].integer

        sale.highestBidCents = json["highest_bid_amount_cents"].integer
        sale.lowEstimateCents = json["low_estimate_cents"].integer
        sale.highEstimateCents = json["high_estimate_cents"].integer
//        let reserveStatus = json["reserve_status"].integer

        return sale;
    }
    
    var estimateString: String {
        switch (lowEstimateCents, highEstimateCents) {
        case let (.Some(lowCents), .Some(highCents)):
            let lowDollars = NSNumberFormatter.currencyStringForCents(lowCents)
            let highDollars = NSNumberFormatter.currencyStringForCents(highCents)
            return "Estimate: \(lowDollars)–\(highDollars)"
        default:
            return "No Estimate"
        }
    }
}

func createDollarFormatter() -> NSNumberFormatter {
    let formatter = NSNumberFormatter()
    formatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle

    // This is always dollars, so let's make sure that's how it shows up
    // regardless of locale.

    formatter.currencyGroupingSeparator = ","
    formatter.currencySymbol = "$"
    formatter.maximumFractionDigits = 0
    return formatter
}<commit_msg>Fixe bidcount.<commit_after>import UIKit

enum ReserveStatus {
    case NoReserve
    case ReserveNotMet(Int)
    case ReserveMet
}

struct SaleNumberFormatter {
    static let dollarFormatter = createDollarFormatter()
}

class SaleArtwork: JSONAble {

    let id: String
    let artwork: Artwork

    var auction: Sale?

    // The bidder is given from JSON if user is registered
    let bidder: Bidder?

    var saleHighestBid: Bid?
    var bidCount: Int?

    var userBidderPosition: BidderPosition?
    var positions: [String]?

    dynamic var openingBidCents: NSNumber?
    var minimumNextBidCents: Int?
    
    var highestBidCents: Int?
    var lowEstimateCents: Int?
    var highEstimateCents: Int?

    init(id: String, artwork: Artwork) {
        self.id = id
        self.artwork = artwork
    }

    override class func fromJSON(json: [String: AnyObject]) -> JSONAble {
        let json = JSON(object: json)

        let id = json["id"].stringValue
        let artworkDict = json["artwork"].object as [String: AnyObject]
        let artwork = Artwork.fromJSON(artworkDict) as Artwork

        let sale = SaleArtwork(id: id, artwork: artwork) as SaleArtwork

        if let highestBidDict = json["highest_bid"].object as? [String: AnyObject] {
            sale.saleHighestBid = Bid.fromJSON(highestBidDict) as? Bid
        }
        
        sale.openingBidCents = json["opening_bid_cents"].integer
        sale.minimumNextBidCents = json["minimum_next_bid_cents"].integer

        sale.highestBidCents = json["highest_bid_amount_cents"].integer
        sale.lowEstimateCents = json["low_estimate_cents"].integer
        sale.highEstimateCents = json["high_estimate_cents"].integer
        sale.bidCount = json["bidder_positions_count"].integer
//        let reserveStatus = json["reserve_status"].integer

        return sale;
    }
    
    var estimateString: String {
        switch (lowEstimateCents, highEstimateCents) {
        case let (.Some(lowCents), .Some(highCents)):
            let lowDollars = NSNumberFormatter.currencyStringForCents(lowCents)
            let highDollars = NSNumberFormatter.currencyStringForCents(highCents)
            return "Estimate: \(lowDollars)–\(highDollars)"
        default:
            return "No Estimate"
        }
    }
}

func createDollarFormatter() -> NSNumberFormatter {
    let formatter = NSNumberFormatter()
    formatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle

    // This is always dollars, so let's make sure that's how it shows up
    // regardless of locale.

    formatter.currencyGroupingSeparator = ","
    formatter.currencySymbol = "$"
    formatter.maximumFractionDigits = 0
    return formatter
}
{'fraction_non_alphanumeric': 0.08659638554216867, 'fraction_numerical': 0.00037650602409638556, 'mean_word_length': 2.959016393442623, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2343986', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1541, 'n_words': 381}