<commit_before>var router = require('express').Router();
var db = require('./database.js');
var milliseconds_in_day = 60*60*24*1000;

db.init();

/**
* Standard API route, returns last database entry
*/
router.get('/', function (req, res) {
	db.getLastEntry(function(row) {
		res.json(row);
	});
});

/**
* Get temperatures in a range from start to end date
* @param :start_date {int} Start date
* @param :end_date {int} End date
*/
router.get('/:start_date/:end_date', function(req, res) {
	db.get(req.params.start_date, req.params.end_date,
	function(rows) {
		res.json(rows);
	});
});

/**
* Get max and min temperature recorded
*/
router.get('/extremes', function(req, res) {
	db.extremes(null, null,
	function(rows) {
		res.json(rows);
	});
});

/**
* Get extremes in a range from start to end date
* @param :start_date {int} Start date
* @param :end_date {int} End date
*/
router.get('/extremes/:start_date/:end_date', function(req, res) {
	db.extremes(req.params.start_date, req.params.end_date,
	function(rows) {
		res.json(rows);
	});
});

/**
* Get all temperature readings from today
*/
router.get('/today', function(req, res) {
	var now = new Date();
	var milliseconds_today = ((now.getHours() * 60 * 60) +
	(now.getMinutes() * 60) + now.getSeconds()) * 1000;

	db.get(now.getTime() - milliseconds_today - 1000, now.getTime(),
	function(rows, test) {
		res.json(rows);
	});
});

/**
* Get all temperature readings from this week
*/
router.get('/week', function(req, res) {
	var now = new Date();
	var milliseconds_today = ((now.getHours() * 60 * 60) +
	(now.getMinutes() * 60) + now.getSeconds()) * 1000;

	db.get(now.getTime() - milliseconds_today - (milliseconds_in_day * 6),
	now.getTime(), function(rows) {
		res.json(rows);
	});
});

/**
* Get all temperature readings from the last 24 hours
*/
router.get('/24hours', function(req, res) {
	var now = new Date();
	db.get(now.getTime() - milliseconds_in_day, now.getTime(),<commit_msg>fixed styling issues<commit_after>var router = require('express').Router();
var db = require('./database.js');
var millisecondsInDay = 60*60*24*1000;

db.init();

/**
* Standard API route, returns last database entry
*/
router.get('/', function (req, res) {
	db.getLastEntry(function(row) {
		res.json(row);
	});
});

/**
* Get temperatures in a range from start to end date
* @param :startDate {int} Start date
* @param :endDate {int} End date
*/
router.get('/:startDate/:endDate', function(req, res) {
	db.get(req.params.startDate, req.params.endDate,
	function(rows) {
		res.json(rows);
	});
});

/**
* Get max and min temperature recorded
*/
router.get('/extremes', function(req, res) {
	db.extremes(null, null,
	function(rows) {
		res.json(rows);
	});
});

/**
* Get extremes in a range from start to end date
* @param :startDate {int} Start date
* @param :endDate {int} End date
*/
router.get('/extremes/:startDate/:endDate', function(req, res) {
	db.extremes(req.params.startDate, req.params.endDate,
	function(rows) {
		res.json(rows);
	});
});

/**
* Get all temperature readings from today
*/
router.get('/today', function(req, res) {
	var now = new Date();
	var millisecondsToday = ((now.getHours() * 60 * 60) +
	(now.getMinutes() * 60) + now.getSeconds()) * 1000;

	db.get(now.getTime() - millisecondsToday - 1000, now.getTime(),
	function(rows, test) {
		res.json(rows);
	});
});

/**
* Get all temperature readings from this week
*/
router.get('/week', function(req, res) {
	var now = new Date();
	var millisecondsToday = ((now.getHours() * 60 * 60) +
	(now.getMinutes() * 60) + now.getSeconds()) * 1000;

	db.get(now.getTime() - millisecondsToday - (millisecondsInDay * 6),
	now.getTime(), function(rows) {
		res.json(rows);
	});
});

/**
* Get all temperature readings from the last 24 hours
*/
router.get('/24hours', function(req, res) {
	var now = new Date();
	db.get(now.getTime() - millisecondsInDay, now.getTime(),
{'fraction_non_alphanumeric': 0.18893178893178894, 'fraction_numerical': 0.020077220077220077, 'mean_word_length': 4.316005471956224, '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': '3027777', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1370, 'n_words': 337}