<commit_before>import Foundation

class FDatabaseModelPurchaseList:FDatabaseModel
{
    let items:[FDatabaseModelPurchase.PurchaseId:FDatabaseModelPurchase]
    
    init(purchases:[MAdminPurchasesItem])
    {
        var items:[FDatabaseModelPurchase.PurchaseId:FDatabaseModelPurchase] = [:]
        
        for purchase:MAdminPurchasesItem in purchases
        {
            let purchaseId:FDatabaseModelPurchase.PurchaseId = purchase.firebasePurchaseId
            let item:FDatabaseModelPurchase = FDatabaseModelPurchase(
                purchase:purchase)
            items[purchaseId] = item
        }
        
        self.items = items
        
        super.init()
    }
    
    required init(snapshot:Any)
    {
        if let rawItems:[FDatabaseModelPurchase.PurchaseId:Any] = snapshot as? [FDatabaseModelPurchase.PurchaseId:Any]
        {
            var items:[FDatabaseModelPurchase.PurchaseId:FDatabaseModelPurchase] = [:]
            let keys:[FDatabaseModelPurchase.PurchaseId] = Array(rawItems.keys)
            
            for rawKey:FDatabaseModelPurchase.PurchaseId in keys
            {
                let rawItem:Any = rawItems[rawKey]
                let item:FDatabaseModelPurchase = FDatabaseModelPurchase(snapshot:rawItem)
                items[rawKey] = item
            }
            
            self.items = items
        }
        else
        {
            items = [:]
        }
        
        super.init()
    }
    
    override init()
    {
        fatalError()
    }
}<commit_msg>building model json from purchase list<commit_after>import Foundation

class FDatabaseModelPurchaseList:FDatabaseModel
{
    let items:[FDatabaseModelPurchase.PurchaseId:FDatabaseModelPurchase]
    
    init(purchases:[MAdminPurchasesItem])
    {
        var items:[FDatabaseModelPurchase.PurchaseId:FDatabaseModelPurchase] = [:]
        
        for purchase:MAdminPurchasesItem in purchases
        {
            let purchaseId:FDatabaseModelPurchase.PurchaseId = purchase.firebasePurchaseId
            let item:FDatabaseModelPurchase = FDatabaseModelPurchase(
                purchase:purchase)
            items[purchaseId] = item
        }
        
        self.items = items
        
        super.init()
    }
    
    required init(snapshot:Any)
    {
        if let rawItems:[FDatabaseModelPurchase.PurchaseId:Any] = snapshot as? [FDatabaseModelPurchase.PurchaseId:Any]
        {
            var items:[FDatabaseModelPurchase.PurchaseId:FDatabaseModelPurchase] = [:]
            let keys:[FDatabaseModelPurchase.PurchaseId] = Array(rawItems.keys)
            
            for rawKey:FDatabaseModelPurchase.PurchaseId in keys
            {
                let rawItem:Any = rawItems[rawKey]
                let item:FDatabaseModelPurchase = FDatabaseModelPurchase(snapshot:rawItem)
                items[rawKey] = item
            }
            
            self.items = items
        }
        else
        {
            items = [:]
        }
        
        super.init()
    }
    
    override init()
    {
        fatalError()
    }
    
    override func modelJson() -> Any
    {
        let itemsKeys:[FDatabaseModelPurchase.PurchaseId] = Array(items.keys)
        var json:[String:Any] = [:]
        
        for itemKey:FDatabaseModelPurchase.PurchaseId in itemsKeys
        {
            let item:FDatabaseModelPurchase = items[itemKey]!
            let jsonItem:Any = item.modelJson()
            json[itemKey] = jsonItem
        }
        
        return json
    }
}
{'fraction_non_alphanumeric': 0.07661634861862718, 'fraction_numerical': 0.0, 'mean_word_length': 1.9315525876460768, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4441307', 'n_tokens_mistral': 995, 'n_tokens_neox': 1001, 'n_words': 144}