Skip to content

Commit 89103f6

Browse files
committed
prettier
1 parent 4d33349 commit 89103f6

10 files changed

Lines changed: 52 additions & 44 deletions

File tree

global.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ type MmrJob = {
282282

283283
type ProfileJob = {
284284
account_id: number;
285-
}
285+
};
286286

287287
type GcDataJob = {
288288
match_id: number;

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"eslint": "^9.19.0",
8282
"mocha": "^11.0.1",
8383
"nock": "^13.5.6",
84-
"prettier": "^3.4.2",
84+
"prettier": "^3.6.2",
8585
"supertest": "^7.0.0",
8686
"tsx": "^4.19.2",
8787
"typescript": "^5.7.3",

svc/autogcdata.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Updates Steam profile data for players periodically
22
import db from './store/db';
3-
import {
4-
invokeIntervalAsync,
5-
randomInt,
6-
} from './util/utility';
3+
import { invokeIntervalAsync, randomInt } from './util/utility';
74
import { addJob } from './store/queue';
85
import { getPGroup } from './util/pgroup';
96
import { apiFetcher } from './fetcher/getApiData';
@@ -13,14 +10,18 @@ async function doGcData() {
1310
// Randomly guess IDs (about 1/2 will be valid) and try to do gcdata on them
1411
// If the API data is missing we'll skip
1512
// Otherwise we'll fetch gcdata (or skip if already present)
16-
const max = (await db.raw('select max(match_id) from public_matches'))
17-
?.rows?.[0]?.max ?? 0;
13+
const max =
14+
(await db.raw('select max(match_id) from public_matches'))?.rows?.[0]
15+
?.max ?? 0;
1816
const rand = randomInt(0, max);
1917
if (rand) {
20-
const { data } = await apiFetcher.getOrFetchData(rand);
21-
if (data) {
22-
await addJob({ name: 'gcQueue', data: { match_id: rand, pgroup: getPGroup(data) }});
23-
}
18+
const { data } = await apiFetcher.getOrFetchData(rand);
19+
if (data) {
20+
await addJob({
21+
name: 'gcQueue',
22+
data: { match_id: rand, pgroup: getPGroup(data) },
23+
});
24+
}
2425
}
2526
}
2627
invokeIntervalAsync(doGcData, 5000);

svc/autoprofiler.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Updates Steam profile data for players periodically
22
import db from './store/db';
3-
import {
4-
invokeIntervalAsync,
5-
} from './util/utility';
3+
import { invokeIntervalAsync } from './util/utility';
64
import { addJob } from './store/queue';
75

86
async function doProfiler() {
@@ -14,8 +12,13 @@ async function doProfiler() {
1412
'SELECT account_id from players TABLESAMPLE SYSTEM_ROWS(100)',
1513
);
1614
// Queue the rows
17-
await Promise.all(result.rows.map(async (row: any) => {
18-
await addJob({ name: 'profileQueue', data: { account_id: row.account_id }});
19-
}));
15+
await Promise.all(
16+
result.rows.map(async (row: any) => {
17+
await addJob({
18+
name: 'profileQueue',
19+
data: { account_id: row.account_id },
20+
});
21+
}),
22+
);
2023
}
2124
invokeIntervalAsync(doProfiler, 5000);

svc/gcdata.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ async function processGcData(job: GcDataJob) {
1111
return;
1212
}
1313
// Currently, just attempt it once and skip if failed
14-
const { data: gcMatch } = await gcFetcher.getOrFetchData(job.match_id, { pgroup });
14+
const { data: gcMatch } = await gcFetcher.getOrFetchData(job.match_id, {
15+
pgroup,
16+
});
1517
// Reconcile anonymous players
1618
await reconcile(gcMatch, pgroup, 'pmh_gcdata');
1719
await new Promise((resolve) => setTimeout(resolve, 10));

svc/mmr.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { runQueue } from './store/queue';
33
import db from './store/db';
44
import { insertPlayerRating } from './util/insert';
55
import config from '../config';
6-
import {
7-
redisCount,
8-
getRandomRetrieverUrl,
9-
} from './util/utility';
6+
import { redisCount, getRandomRetrieverUrl } from './util/utility';
107
import axios from 'axios';
118

129
async function processMmr(job: MmrJob) {
@@ -34,8 +31,4 @@ async function processMmr(job: MmrJob) {
3431
}
3532
await new Promise((resolve) => setTimeout(resolve, 1));
3633
}
37-
runQueue(
38-
'mmrQueue',
39-
Number(config.MMR_PARALLELISM) || 1,
40-
processMmr,
41-
);
34+
runQueue('mmrQueue', Number(config.MMR_PARALLELISM) || 1, processMmr);

svc/monitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async function profileDelay() {
133133
const result = await redis.llen('profileQueue');
134134
return {
135135
metric: result,
136-
threshold: 100000
136+
threshold: 100000,
137137
};
138138
}
139139
async function postgresUsage() {

svc/profiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function doProfile() {
1515
if (!resp || !resp.length) {
1616
return;
1717
}
18-
const jobs = resp.map(item => JSON.parse(item) as ProfileJob);
18+
const jobs = resp.map((item) => JSON.parse(item) as ProfileJob);
1919
const url = SteamAPIUrls.api_summaries({
2020
players: jobs,
2121
});
@@ -45,4 +45,4 @@ async function doProfile() {
4545
results.map((player: User) => upsertPlayer(db, player, false)),
4646
);
4747
}
48-
invokeIntervalAsync(doProfile, 2000);
48+
invokeIntervalAsync(doProfile, 2000);

svc/util/insert.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,25 @@ export async function insertPlayerRating(row: PlayerRating) {
129129
}
130130
}
131131

132-
export async function reconcile(gcMatch: GcMatch | null, pgroup: PGroup, metricName: MetricName) {
132+
export async function reconcile(
133+
gcMatch: GcMatch | null,
134+
pgroup: PGroup,
135+
metricName: MetricName,
136+
) {
133137
if (gcMatch) {
134138
// Log the players who were previously anomymous for reconciliation
135-
await Promise.all(gcMatch.players
136-
.filter(p => !Boolean(pgroup[p.player_slot]?.account_id))
137-
.map(async (p) => {
138-
if (p.account_id) {
139-
await db.raw('INSERT INTO player_match_history(account_id, match_id, player_slot) VALUES (?, ?, ?) ON CONFLICT DO NOTHING', [p.account_id, gcMatch.match_id, p.player_slot]);
140-
await redisCount(metricName);
141-
}
142-
})
139+
await Promise.all(
140+
gcMatch.players
141+
.filter((p) => !Boolean(pgroup[p.player_slot]?.account_id))
142+
.map(async (p) => {
143+
if (p.account_id) {
144+
await db.raw(
145+
'INSERT INTO player_match_history(account_id, match_id, player_slot) VALUES (?, ?, ?) ON CONFLICT DO NOTHING',
146+
[p.account_id, gcMatch.match_id, p.player_slot],
147+
);
148+
await redisCount(metricName);
149+
}
150+
}),
143151
);
144152
}
145153
}

0 commit comments

Comments
 (0)