<commit_before>//
//  User.swift
//  SumDUBot
//
//  Created by <NAME> on 02.04.17.
//
//

import Vapor
import Fluent
import Foundation

final class User: Model {

    // MARK: Properties

    var id: Node?
    var exists: Bool = false

    var chatID: Int
    var firstName: String?
    var lastName: String?
    var requests: Int

    // MARK: - Initialization

    init(node: Node, in context: Context) throws {
        id = try node.extract("id")
        chatID = try node.extract("chat_id")
        firstName = try node.extract("first_name")
        lastName = try node.extract("last_name")
        requests = try node.extract("requests")
    }

    func makeNode(context: Context) throws -> Node {
        return try Node(node: [
            "id": id,
            "chat_id": chatID,
            "first_name": firstName,
            "last_name": lastName,
            "requests": requests
            ])
    }

    init?(_ object: [String: Polymorphic]) {
        guard let chatID = object["id"]?.int else { return nil }
        self.chatID = chatID
        self.firstName = object["first_name"]?.string
        self.lastName = object["last_name"]?.string
        self.requests = 0
    }
}

// MARK: - Preparation

extension User: Preparation {

    static func prepare(_ database: Database) throws {
        try database.create(entity, closure: { user in
            user.id()
            user.int("chat_id")
            user.string("first_name")
            user.string("last_name")
            user.int("requests")
        })
    }

    static func revert(_ database: Database) throws {
        try database.delete(entity)
    }
}
<commit_msg>Fixed bug in User model<commit_after>//
//  User.swift
//  SumDUBot
//
//  Created by <NAME> on 02.04.17.
//
//

import Vapor
import Fluent
import Foundation

final class User: Model {

    // MARK: Properties

    var id: Node?
    var exists: Bool = false

    var chatID: Int
    var firstName: String?
    var lastName: String?
    var requests: Int

    // MARK: - Initialization

    init(node: Node, in context: Context) throws {
        id = try node.extract("id")
        chatID = try node.extract("chat_id")
        firstName = try node.extract("first_name")
        lastName = try node.extract("last_name")
        requests = try node.extract("requests")
    }

    func makeNode(context: Context) throws -> Node {
        return try Node(node: [
            "id": id,
            "chat_id": chatID,
            "first_name": firstName,
            "last_name": lastName,
            "requests": requests
            ])
    }

    init?(_ object: [String: Polymorphic]) {
        guard let chatID = object["id"]?.int else { return nil }
        self.chatID = chatID
        self.firstName = object["first_name"]?.string
        self.lastName = object["last_name"]?.string
        self.requests = 0
    }
}

// MARK: - Preparation

extension User: Preparation {

    static func prepare(_ database: Database) throws {
        try database.create(entity, closure: { user in
            user.id()
            user.int("chat_id")
            user.string("first_name", optional: true)
            user.string("last_name", optional: true)
            user.int("requests")
        })
    }

    static func revert(_ database: Database) throws {
        try database.delete(entity)
    }
}
{'fraction_non_alphanumeric': 0.12025127131319174, 'fraction_numerical': 0.004187855219862399, 'mean_word_length': 2.023508137432188, 'pattern_counts': {'":': 10, '<': 5, '<?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': '2202761', 'n_tokens_mistral': 1014, 'n_tokens_neox': 963, 'n_words': 264}