<commit_before>

var jest = require('jest')
    ,models = require('../../models')
    ,common = require('../common')
    ,async = require('async')
    ,_ = require('underscore');

var CycleTimelineResource = module.exports = jest.Resource.extend({
    init:function(){
        this._super();
        this.allowed_methods = {
            get: {
                list:null
            }
        };
        this.authentication = new common.SessionAuthentication();
        this.filtering = {};
        this.sorting = {};
    },

    get_objects:function(req,filters,sorts,limit,offset,callback)
    {
        var arr = [];
        var cycle_id = req.query.cycle_id;
        async.parallel([
            function(cbk){
                    models.Cycle.findById(cycle_id, function(err, cycle){
                    if(!err){
                        var objs = [];
                        if(cycle){
                            _.each(cycle.admin_updates, function(admin_update){
                                if(admin_update){
                                    var obj = {
                                        type: "admin_update",
                                        text: admin_update.info,
                                        date: admin_update.date
                                    }
                                    objs.push(obj);
                                }
                            })

                            if(cycle.due_date){
                                var obj = {
                                    type: "due_date",
                                    date: cycle.due_date
                                }
                                objs.push(obj);
                            }

                            var obj = {
                                type: "cycle_creation",
                                date: cycle.creation_date
                            }

                            objs.push(obj);

                            //set date to today after midnight
                            var date = new Date();
                            date.setHours(0,0,0,1);

                            var obj = {
                                type: "today",
                                date: date
                            }

                            objs.push(obj);

                            var discussion = _.find(cycle.discussions, function(discussion){ return discussion.is_main == true});
                            if(discussion){
                                models.Discussion.findById(discussion.discussion)
                                    .select({'_id': 1, 'title': 1, 'text_field_preivew': 1, 'image_field_preview': 1, 'creation_date': 1})
                                    .exec(function(err, discussion_obj){
                                        if(!err && discussion_obj){
                                            discussion_obj = JSON.parse(JSON.stringify(discussion_obj));
                                            discussion_obj.type = "discussion";
                                            discussion_obj.date = discussion_obj.creation_date;<commit_msg>timeline - set today time to 1 sec after midnight<commit_after>

var jest = require('jest')
    ,models = require('../../models')
    ,common = require('../common')
    ,async = require('async')
    ,_ = require('underscore');

var CycleTimelineResource = module.exports = jest.Resource.extend({
    init:function(){
        this._super();
        this.allowed_methods = {
            get: {
                list:null
            }
        };
        this.authentication = new common.SessionAuthentication();
        this.filtering = {};
        this.sorting = {};
    },

    get_objects:function(req,filters,sorts,limit,offset,callback)
    {
        var arr = [];
        var cycle_id = req.query.cycle_id;
        async.parallel([
            function(cbk){
                    models.Cycle.findById(cycle_id, function(err, cycle){
                    if(!err){
                        var objs = [];
                        if(cycle){
                            _.each(cycle.admin_updates, function(admin_update){
                                if(admin_update){
                                    var obj = {
                                        type: "admin_update",
                                        text: admin_update.info,
                                        date: admin_update.date
                                    }
                                    objs.push(obj);
                                }
                            })

                            if(cycle.due_date){
                                var obj = {
                                    type: "due_date",
                                    date: cycle.due_date
                                }
                                objs.push(obj);
                            }

                            var obj = {
                                type: "cycle_creation",
                                date: cycle.creation_date
                            }

                            objs.push(obj);

                            //set date to today after midnight
                            var date = new Date();
                            date.setHours(0,0,0,1);
                            //set date to one sec after midnight
                            var new_date = new Date(date - 21 * 1000 * 60 * 60);

                            var obj = {
                                type: "today",
                                date: new_date
                            }

                            objs.push(obj);

                            var discussion = _.find(cycle.discussions, function(discussion){ return discussion.is_main == true});
                            if(discussion){
                                models.Discussion.findById(discussion.discussion)
                                    .select({'_id': 1, 'title': 1, 'text_field_preivew': 1, 'image_field_preview': 1, 'creation_date': 1})
                                    .exec(function(err, discussion_obj){
                                        if(!err && discussion_obj){
                                            discussion_obj = JSON.parse(JSON.stringify(discussion_obj));
                                            discussion_obj.type = "discussion";
                                            discussion_obj.date = discussion_obj.creation_date;
{'fraction_non_alphanumeric': 0.08949953945348481, 'fraction_numerical': 0.004451949646914338, 'mean_word_length': 0.816787506971556, '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': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5197820', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1333, 'n_words': 250}