Skip to content

Commit 2dbe6a2

Browse files
committed
Summarize: Need to transform timeout count to rate
1 parent c5d9b9f commit 2dbe6a2

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

utils/summarize.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -530,16 +530,6 @@ export const handler: Handler = async (event: any, context?: any) => {
530530
}
531531
}
532532

533-
// timeouts
534-
for (const t of siteTimeouts) {
535-
const daysAgo = (baseline - t) / (24 * 60 * 60 * 1000);
536-
const bucket = Math.floor(daysAgo / 7);
537-
histTimeoutBuckets.push(bucket);
538-
}
539-
for (let i = 0; i <= Math.max(...histTimeoutBuckets); i++) {
540-
histTimeouts.push(histTimeoutBuckets.filter(x => x === i).length);
541-
}
542-
543533
// all games
544534
const histAll: number[] = [];
545535
const histAllPlayers: number[] = [];
@@ -552,6 +542,21 @@ export const handler: Handler = async (event: any, context?: any) => {
552542
}
553543
histAllPlayers.push(users.size);
554544
}
545+
546+
// timeouts
547+
for (const t of siteTimeouts) {
548+
const daysAgo = (baseline - t) / (24 * 60 * 60 * 1000);
549+
const bucket = Math.floor(daysAgo / 7);
550+
histTimeoutBuckets.push(bucket);
551+
}
552+
for (let i = 0; i <= Math.max(...histTimeoutBuckets); i++) {
553+
histTimeouts.push(histTimeoutBuckets.filter(x => x === i).length);
554+
}
555+
// convert to rate
556+
for (let i = 0; i < histTimeouts.length; i++) {
557+
histTimeouts[i] = histTimeouts[i] / histAll[i];
558+
}
559+
555560
const histMeta: GameNumList[] = [];
556561
const recent: GameNumber[] = [];
557562
for (const meta of meta2recs.keys()) {

0 commit comments

Comments
 (0)