Skip to content

Commit

Permalink
use invokeinterval for livegames
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 4, 2023
1 parent cbd0f9a commit c88a35f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion svc/gcdata.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Processes a queue of requests for gcdata (replay salts) without parsing
// The parser will also request gcdata if needed
import getGcData from '../util/getGcData.mjs';
import getGcData from '../store/getGcData.mjs';
import queue from '../store/queue.mjs';
import config from '../config.js';
import utility from '../util/utility.mjs';
Expand Down
1 change: 1 addition & 0 deletions svc/leagues.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import utility from '../util/utility.mjs';
import db from '../store/db.mjs';
import queries from '../store/queries.mjs';
const { invokeInterval, generateJob, getData } = utility;

function doLeagues(cb) {
const container = generateJob('api_leagues', {});
getData(container.url, (err, apiLeagues) => {
Expand Down
3 changes: 2 additions & 1 deletion svc/livegames.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import request from 'request';
import redis from '../store/redis.mjs';
import db from '../store/db.mjs';
import config from '../config.js';
import { invokeInterval } from '../util/utility.mjs';
function doLiveGames(cb) {
// Get the list of pro players
db.select()
Expand Down Expand Up @@ -58,4 +59,4 @@ function doLiveGames(cb) {
});
});
}
setInterval(doLiveGames, 60 * 1000);
invokeInterval(doLiveGames, 60 * 1000);
2 changes: 1 addition & 1 deletion util/utility.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ function getRedisCountHour(redis, prefix, cb) {
}
redis.pfcount(...keyArr, cb);
}
function invokeInterval(func, delay) {
export function invokeInterval(func, delay) {
// invokes the function immediately, waits for callback, waits the delay, and then calls it again
(function invoker() {
console.log('running %s', func.name);
Expand Down

0 comments on commit c88a35f

Please sign in to comment.