Skip to content

Commit

Permalink
do unparsed benchmarks and simplify insert stack
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Nov 29, 2023
1 parent c6a93e5 commit 26bae0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 37 deletions.
27 changes: 5 additions & 22 deletions store/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,23 +1070,6 @@ function insertMatch(match, options, cb) {
cb();
}

function tellFeed(cb) {
if (options.origin === "scanner" || options.doTellFeed) {
redis.xadd(
"feed",
"maxlen",
"~",
"100",
"*",
"data",
JSON.stringify({ ...match, origin: options.origin }),
cb
);
} else {
cb();
}
}

function decideLogParse(cb) {
if (match.leagueid) {
db.select("leagueid")
Expand Down Expand Up @@ -1464,14 +1447,15 @@ function insertMatch(match, options, cb) {
}

function decideScenarios(cb) {
if (options.doScenarios) {
if (options.type === 'parsed' &&
match.match_id % 100 < config.SCENARIOS_SAMPLE_PERCENT) {
return redis.rpush("scenariosQueue", match.match_id, cb);
}
return cb();
}

function decideParsedBenchmarks(cb) {
if (options.doParsedBenchmarks) {
function decideBenchmarks(cb) {
if (options.origin === "scanner" && match.match_id % 100 < config.BENCHMARKS_SAMPLE_PERCENT) {
return redis.rpush("parsedBenchmarksQueue", match.match_id, cb);
}
return cb();
Expand Down Expand Up @@ -1606,7 +1590,6 @@ function insertMatch(match, options, cb) {
async.series(
{
preprocess,
tellFeed,
decideLogParse,
updateMatchGcData,
upsertMatch,
Expand All @@ -1619,7 +1602,7 @@ function insertMatch(match, options, cb) {
telemetry,
decideCounts,
decideScenarios,
decideParsedBenchmarks,
decideBenchmarks,
decideMmr,
decideProfile,
decideGcData,
Expand Down
4 changes: 2 additions & 2 deletions svc/benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const redis = require("../store/redis");

const { benchmarks } = benchmarksUtil;

async function doParsedBenchmarks(matchID, cb) {
async function doBenchmarks(matchID, cb) {
try {
const match = await buildMatch(matchID);
if (match.players && utility.isSignificant(match)) {
Expand Down Expand Up @@ -50,4 +50,4 @@ async function doParsedBenchmarks(matchID, cb) {
}
}

queue.runQueue("parsedBenchmarksQueue", 1, doParsedBenchmarks);
queue.runQueue("parsedBenchmarksQueue", 1, doBenchmarks);
7 changes: 0 additions & 7 deletions svc/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ function runParse(match, job, cb) {
type: "parsed",
skipParse: true,
doLogParse: match.doLogParse,
doScenarios:
match.origin === "scanner" &&
match.match_id % 100 < config.SCENARIOS_SAMPLE_PERCENT,
doParsedBenchmarks:
match.origin === "scanner" &&
match.match_id % 100 < config.BENCHMARKS_SAMPLE_PERCENT,
doTellFeed: match.origin === "scanner",
},
cb
);
Expand Down
12 changes: 6 additions & 6 deletions util/benchmarksUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const benchmarks = {
tower_damage(m, p) {
return p.tower_damage;
},
stuns_per_min(m, p) {
return (p.stuns / m.duration) * 60;
},
lhten(m, p) {
return p.lh_t && p.lh_t[10];
},
// stuns_per_min(m, p) {
// return (p.stuns / m.duration) * 60;
// },
// lhten(m, p) {
// return p.lh_t && p.lh_t[10];
// },
};

module.exports = {
Expand Down

0 comments on commit 26bae0b

Please sign in to comment.