"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const db_1 = require("../db");
class default_1 {
    static createOne(modal) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            let needUpdate = false;
            const item = db_1.db.get('statistics').find({
                project_id: modal.project_id
            }).value();
            if (!item) {
                needUpdate = true;
            }
            else {
                needUpdate = item.component_name !== modal.component_name
                    || JSON.stringify(item.component_list) !== JSON.stringify(modal.component_list);
            }
            yield db_1.db.get('statistics')
                .updateOrAdd(modal, 'project_id')
                .write();
            return Object.assign({ needUpdate }, modal);
        });
    }
}
exports.default = default_1;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdGlzdGljcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXJ2aWNlL3N0YXRpc3RpY3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsOEJBQTBCO0FBSTFCO0lBQ0UsTUFBTSxDQUFPLFNBQVMsQ0FBQyxLQUdlOztZQUVwQyxJQUFJLFVBQVUsR0FBRyxLQUFLLENBQUE7WUFFdEIsTUFBTSxJQUFJLEdBQUcsT0FBRSxDQUFDLEdBQUcsQ0FBQyxZQUFZLENBQUMsQ0FBQyxJQUFJLENBQUM7Z0JBQ3JDLFVBQVUsRUFBRSxLQUFLLENBQUMsVUFBVTthQUM3QixDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7WUFFVixJQUFHLENBQUMsSUFBSSxFQUFFO2dCQUNSLFVBQVUsR0FBRyxJQUFJLENBQUE7YUFDbEI7aUJBQU07Z0JBQ0wsVUFBVSxHQUFHLElBQUksQ0FBQyxjQUFjLEtBQUssS0FBSyxDQUFDLGNBQWM7dUJBQ3RELElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxLQUFLLElBQUksQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLGNBQWMsQ0FBQyxDQUFBO2FBQ2hGO1lBRUQsTUFBTSxPQUFFLENBQUMsR0FBRyxDQUFDLFlBQVksQ0FBQztpQkFDdkIsV0FBVyxDQUFDLEtBQUssRUFBRSxZQUFZLENBQUM7aUJBQ2hDLEtBQUssRUFBRSxDQUFBO1lBRVYsdUJBQ0UsVUFBVSxJQUNQLEtBQUssRUFDVDtRQUNILENBQUM7S0FBQTtDQUNGO0FBNUJELDRCQTRCQyJ9