<commit_before>const JsonDB = require('node-json-db');
const moment = require('moment');

let database = new JsonDB("data/db", true, true);

const giveaways = database.getData("/sg-giveaways");
let sc_statuses = database.getData("/sc-status");
const manual_mark = database.getData("/manual-mark");
sc_statuses.beaten = sc_statuses.beaten.concat(manual_mark.beaten);
sc_statuses.blacklisted = sc_statuses.blacklisted.concat(manual_mark.blacklisted);

let statistics = {
    "blacklisted": 0,
    "beaten": 0,
    "active": 0,
    "played": 0
};

let flag;
for (giveaway of giveaways) {
    flag = false;
    for (stat of Object.keys(statistics)) {
        for (sc_status of sc_statuses[stat]) {
            if (giveaway.game.steamid == sc_status.steamid) {
                flag = true;
                statistics[stat]++;
                break;
            }
        }
        if (flag) {
            break;
        }
    }
}

delete statistics.played;
statistics.backlog = (giveaways.length) - (statistics.blacklisted + statistics.beaten + statistics.active);
let statistic_data = {};
statistic_data[moment(new Date).isoWeek() - 1] = statistics;

database.push("/statistics", statistic_data);<commit_msg>another minor fix<commit_after>const JsonDB = require('node-json-db');
const moment = require('moment');

let database = new JsonDB("data/db", true, true);

const giveaways = database.getData("/sg-giveaways");
let sc_statuses = database.getData("/sc-status");
const manual_mark = database.getData("/manual-mark");
sc_statuses.beaten = sc_statuses.beaten.concat(manual_mark.beaten);
sc_statuses.blacklisted = sc_statuses.blacklisted.concat(manual_mark.blacklisted);

let statistics = {
    "blacklisted": 0,
    "beaten": 0,
    "active": 0,
    "played": 0
};

let flag;
for (giveaway of giveaways) {
    flag = false;
    for (stat of Object.keys(statistics)) {
        for (sc_status of sc_statuses[stat]) {
            if (giveaway.game.steamid == sc_status.steamid) {
                flag = true;
                statistics[stat]++;
                break;
            }
        }
        if (flag) {
            break;
        }
    }
}

delete statistics.played;
statistics.backlog = (giveaways.length) - (statistics.blacklisted + statistics.beaten + statistics.active);
database.push("/statistics/" + (moment(new Date).isoWeek() - 1), statistics);
{'fraction_non_alphanumeric': 0.14085702163767502, 'fraction_numerical': 0.004242681374628765, 'mean_word_length': 3.051546391752577, 'pattern_counts': {'":': 8, '<': 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': '299171', 'n_tokens_mistral': 771, 'n_tokens_neox': 729, 'n_words': 150}