<commit_before>var eventStore      = require('./eventStore');
var eventType       = require('./eventType');
var logger          = require('./logger');
var knex            = require('./dbPool');
var STRATEGY_COLUMNS = ['name', 'description', 'parameters_template'];

eventStore.on(eventType.strategyCreated, function (event) {
    knex('strategies')
        .insert(eventToRow(event))
        .catch(function (err) {
            logger.error('Could not insert strategy, error was: ', err);
        });
});

function getStrategies() {
    return knex
        .select(STRATEGY_COLUMNS)
        .from('strategies')
        .orderBy('created_at', 'desc')
        .map(rowToStrategy);
}

function getStrategy(name) {
    return knex
        .first(STRATEGY_COLUMNS)<commit_msg>strategies should be order after createdAt ASC<commit_after>var eventStore      = require('./eventStore');
var eventType       = require('./eventType');
var logger          = require('./logger');
var knex            = require('./dbPool');
var STRATEGY_COLUMNS = ['name', 'description', 'parameters_template'];

eventStore.on(eventType.strategyCreated, function (event) {
    knex('strategies')
        .insert(eventToRow(event))
        .catch(function (err) {
            logger.error('Could not insert strategy, error was: ', err);
        });
});

function getStrategies() {
    return knex
        .select(STRATEGY_COLUMNS)
        .from('strategies')
        .orderBy('created_at', 'asc')
        .map(rowToStrategy);
}

function getStrategy(name) {
    return knex
        .first(STRATEGY_COLUMNS)
{'fraction_non_alphanumeric': 0.14358322744599747, 'fraction_numerical': 0.0, 'mean_word_length': 2.9276807980049875, 'pattern_counts': {'":': 0, '<': 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': '3051549', 'n_tokens_mistral': 473, 'n_tokens_neox': 464, 'n_words': 95}