lot/app.js

40 lines
751 B
JavaScript
Raw Normal View History

2017-09-08 09:45:53 +00:00
const loader = require('./libs/loader');
const lot = require('./libs/lot');
const lotv2 = require('./libs/lotV2');
const pusher = require('./libs/pusher');
2017-09-08 09:49:24 +00:00
const log4js = require('log4js');
const logger = log4js.getLogger();
2017-09-08 09:51:39 +00:00
const cron = require('node-cron');
2017-09-08 09:45:53 +00:00
2017-09-08 09:54:07 +00:00
logger.level = 'debug';
2017-09-08 09:45:53 +00:00
function run(data) {
const v1 = lot.calculate(data);
const v2 = lotv2.calculate(data);
const msg =
`V2: ${v2} stars: ${v1.mainstars}
V1: ${v1.mainline} stars: ${v1.mainstars}
Other: ${v1.otherLine} stars: ${v1.otherStars}
`;
pusher.push(msg);
2017-09-08 09:49:24 +00:00
logger.debug(msg);
2017-09-08 09:45:53 +00:00
loader.save(data);
}
function go() {
2017-09-08 09:49:24 +00:00
logger.info('GO!');
2017-09-08 09:45:53 +00:00
loader.load(run);
}
2017-09-08 09:49:24 +00:00
cron.schedule('10 13 * * 2,5', () => {
2017-09-08 09:45:53 +00:00
go();
2017-09-08 09:49:24 +00:00
2017-09-08 09:45:53 +00:00
return -1;
});
2017-09-08 09:49:24 +00:00
logger.info('Lot V3 started...');