<commit_before>'use strict';

const model = require('../../mongo/model');
const aggregation = require('../../mongo/models/aggregation');

exports.getData = function* (next) {
    const since = +this.query.since || 0;
    const limit = +this.query.limit || 100;
    const db = this.params.name;

    const Model = yield model.getAggregationIfExists(db);
    var d;
    if(!Model) {
        d = [];
    } else {
        d = yield Model.find({seqid: {$gt: since}})
            .sort({seqid: 'asc'})
            .select({_id: 0, __v: 0})
            .limit(limit).lean(true).exec();
    }


    var body = {
        lastSeqId: d.length ? d[d.length-1].seqid : 0,
        data: d
    };

    this.body = body;
    this.status = 200;

    yield next;
};

exports.getInfo = function * (next) {
    const since = +this.query.since || 0;
    const db = this.params.name;

    const Model = yield model.getAggregationIfExists(db);
    if(!Model) {
        this.body = {
            data: {
                remaining: 0,
                total: 0
            }
        }
    } else {
        this.body = {
            remaining: yield Model.count({seqid: {$gt: since}}),
            total: yield Model.count()
        }
    }

    this.status = 200;
    yield next;
};<commit_msg>fix error on sync (#23)<commit_after>'use strict';

const model = require('../../mongo/model');
const aggregation = require('../../mongo/models/aggregation');

exports.getData = function* (next) {
    const since = +this.query.since || 0;
    const limit = +this.query.limit || 100;
    const db = this.params.name;

    const Model = yield model.getAggregationIfExists(db);
    var d;
    if(!Model) {
        d = [];
    } else {
        d = yield Model.find({seqid: {$gt: since}})
            .sort({seqid: 'asc'})
            .select({_id: 0, __v: 0})
            .limit(limit).lean(true).exec();
    }


    var body = {
        lastSeqId: d.length ? d[d.length-1].seqid : 0,
        data: d
    };

    this.body = body;
    this.status = 200;

    yield next;
};

exports.getInfo = function * (next) {
    const since = +this.query.since || 0;
    const db = this.params.name;

    const Model = yield model.getAggregationIfExists(db);
    if(!Model) {
        this.body = {
            data: {
                remaining: 0,
                total: 0
            }
        }
    } else {
        this.body = {
            data: {
                remaining: yield Model.count({seqid: {$gt: since}}),
                total: yield Model.count()
            }
        }
    }

    this.status = 200;
    yield next;
};
{'fraction_non_alphanumeric': 0.15687789799072643, 'fraction_numerical': 0.013910355486862442, 'mean_word_length': 1.7138364779874213, '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': '6685293', 'n_tokens_mistral': 867, 'n_tokens_neox': 817, 'n_words': 189}