<commit_before>'use strict';

/**
 * Module dependencies.
 */

var mongoose = require('mongoose'),
    Block = mongoose.model('Block');
//, _ = require('lodash');


/**
 * Find block by hash ...
 */
exports.block = function(req, res, next, hash) {
  Block.fromHashWithInfo(hash, function(err, block) {
    if (err) return next(err);
    if (!block) return next(new Error('Failed to load block ' + hash));
    req.block = block.info;
    next();
  });
};


/**
 * Show block
 */
exports.show = function(req, res) {
  res.jsonp(req.block);
};

/**
 * List of blocks at HomePage
 */
exports.last_blocks = function(req, res) {
  Block.find().sort({time:-1}).limit(7).exec(function(err, blocks) {
    if (err) {
      res.render('error', {
        status: 500
      });
    } else {
      res.jsonp(blocks);
    }
  });
};

/**
 * List of blocks by date
 */
exports.list = function(req, res) {
  var findParam = {};

  if (req.query.blockDate) {
    findParam = {};
  }

  Block
    .find(findParam)
    .limit(5)
    .exec(function(err, blocks) {
      if (err) {
        res.render('error', {
          status: 500
        });
      } else {
        res.jsonp(blocks);
      }
    });
};
<commit_msg>blocks controller improved to find blocks by date<commit_after>'use strict';

/**
 * Module dependencies.
 */

var mongoose = require('mongoose'),
    Block = mongoose.model('Block');
//, _ = require('lodash');


/**
 * Find block by hash ...
 */
exports.block = function(req, res, next, hash) {
  Block.fromHashWithInfo(hash, function(err, block) {
    if (err) return next(err);
    if (!block) return next(new Error('Failed to load block ' + hash));
    req.block = block.info;
    next();
  });
};


/**
 * Show block
 */
exports.show = function(req, res) {
  res.jsonp(req.block);
};

/**
 * List of blocks at HomePage
 */
exports.last_blocks = function(req, res) {
  Block.find().sort({time:-1}).limit(7).exec(function(err, blocks) {
    if (err) {
      res.render('error', {
        status: 500
      });
    } else {
      res.jsonp(blocks);
    }
  });
};

/**
 * List of blocks by date
 */
exports.list = function(req, res) {
  var findParam = {};

  if (req.query.blockDate) {
    var gte = Math.round((new Date(req.query.blockDate)).getTime() / 1000);
    var lte = gte + 86400;

    findParam = { time: {
      '$gte': gte,
      '$lte': lte
    }};
  }

  Block
    .find(findParam)
    .limit(5)
    .exec(function(err, blocks) {
      if (err) {
        res.render('error', {
          status: 500
        });
      } else {
        res.jsonp(blocks);
      }
    });
};


1296688602



1296615600

1296615600000



{'fraction_non_alphanumeric': 0.18257892734880182, 'fraction_numerical': 0.022822365918600228, 'mean_word_length': 2.384813384813385, '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': '630161', 'n_tokens_mistral': 964, 'n_tokens_neox': 914, 'n_words': 196}