Skip to content

Commit

Permalink
fix data from health metric
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 4, 2023
1 parent c88a35f commit 1d80108
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions store/buildStatus.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ export default function buildStatus(db, redis, cb) {
},
seqNumDelay(cb) {
// It's slow to query Steam API so use the value saved by monitor
redis.hget('health', 'seqNumDelay', cb);
redis.hget('health', 'seqNumDelay', (err, data) => {
cb(err, JSON.parse(data).metric)
});
},
parseQueue(cb) {
// It's slow to count in postgres so use the value saved by monitor
redis.hget('health', 'parseDelay', cb);
redis.hget('health', 'parseDelay', (err, data) => {
cb(err, JSON.parse(data).metric);
});
},
fhQueue(cb) {
redis.llen('fhQueue', cb);
Expand Down
2 changes: 1 addition & 1 deletion svc/profiler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import queries from '../store/queries.mjs';
import db from '../store/db.mjs';
import utility from '../util/utility.mjs';
const { insertPlayerPromise, bulkIndexPlayer } = queries;
const { getData, generateJob, convert64to32 } = utility;
const { getDataPromise, generateJob, convert64to32 } = utility;

while (true) {
// To optimize the api call we need to do 100 players at a time
Expand Down
4 changes: 3 additions & 1 deletion svc/proplayers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import utility from '../util/utility.mjs';
const { generateJob, getDataPromise } = utility;

while (true) {
console.time('doProPlayers');
const container = generateJob('api_notable', {});
const body = await getDataPromise(container.url);
await Promise.all(
await Promise.all(
body.player_infos.map((p) =>
queries.upsertPromise(db, 'notable_players', p, {
account_id: p.account_id,
})
)
);
console.timeEnd('doProPlayers');
await new Promise((resolve) => setTimeout(resolve, 30 * 60 * 1000));
}

0 comments on commit 1d80108

Please sign in to comment.