<commit_before>import sqlite from 'sqlite'
import winston from 'winston'

export default class Community {
    static async init() {
        if (this.db) { return }
        this.db = await sqlite.open('/data/community.sqlite3').catch(winston.error)
        await this.db
            .run('CREATE TABLE IF NOT EXISTS villagers (guildId INTEGER, userId INTEGER, bnetServer TEXT, bnetId TEXT, PRIMARY KEY(guildId, userId, bnetServer))')
            .catch(winston.error)
    }
}
<commit_msg>Add automated, timed removal of quests<commit_after>import sqlite from 'sqlite'
import winston from 'winston'

export default class Community {
    static async init() {
        if (this.db) { return }
        this.db = await sqlite.open('/data/community.sqlite3').catch(winston.error)
        await this.db
            .run('CREATE TABLE IF NOT EXISTS villagers (guildId INTEGER, userId INTEGER, bnetServer TEXT, bnetId TEXT, PRIMARY KEY(guildId, userId, bnetServer))')
            .catch(winston.error)
        await this.db
            .run('CREATE TABLE IF NOT EXISTS quests (guildId INTEGER, userId INTEGER, bnetServer TEXT, bnetId TEXT, createdAt INTEGER, PRIMARY KEY(guildId, userId, bnetServer))')
            .catch(winston.error)
        setTimeout(async () => { await this.dropOldQuests() }, (10 * 60 * 1000))
    }

    static async dropOldQuests() {
        winston.verbose('Auto-deleting quests that more than 1 day old.')
        const oneDayAgo = new Date()
        oneDayAgo.setDate(oneDayAgo.getDate() + 1)
        const oldestTimestamp = Math.floor(oneDayAgo / 1000)
        await this.db.all('DELETE FROM quests WHERE createdAt < ?', oldestTimestamp)
    }
}

{'fraction_non_alphanumeric': 0.10617876424715057, 'fraction_numerical': 0.009598080383923215, 'mean_word_length': 3.0096153846153846, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2103352', 'n_tokens_mistral': 541, 'n_tokens_neox': 501, 'n_words': 146}