Skip to content

Commit d6c3716

Browse files
committed
wip
1 parent 4e42ccc commit d6c3716

2 files changed

Lines changed: 29 additions & 37 deletions

File tree

src/demos/demo-metadata.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class DemoMetadataService {
104104
workshop_id: true,
105105
cs2_build: true,
106106
metadata_parsed_at: true,
107-
} as any,
107+
},
108108
});
109109
return (match_map_demos[0] as DemoRow) ?? null;
110110
}
@@ -123,7 +123,7 @@ export class DemoMetadataService {
123123
workshop_id: true,
124124
cs2_build: true,
125125
metadata_parsed_at: true,
126-
} as any,
126+
},
127127
});
128128
return (match_map_demos_by_pk as DemoRow) ?? null;
129129
}
@@ -148,7 +148,7 @@ export class DemoMetadataService {
148148
workshop_id: parsed.workshop_id ?? null,
149149
cs2_build: parsed.cs2_build ?? null,
150150
metadata_parsed_at: "now()",
151-
} as any,
151+
},
152152
},
153153
id: true,
154154
},

src/matches/game-streamer/game-streamer.service.ts

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ export class GameStreamerService {
156156
match_id: { _eq: matchId },
157157
is_game_streamer: { _eq: true },
158158
},
159-
// Generated Hasura types lag this migration until codegen runs.
160-
_set: { autodirector: enabled } as any,
159+
_set: { autodirector: enabled },
161160
},
162161
affected_rows: true,
163162
},
@@ -236,7 +235,7 @@ export class GameStreamerService {
236235
const streamUrl = `${this.appConfig.gameStreamHlsBase}/${matchId}/`;
237236

238237
const bootIso = new Date().toISOString();
239-
const insertRes = await this.hasura.mutation({
238+
const { insert_match_demo_sessions_one } = await this.hasura.mutation({
240239
insert_match_demo_sessions_one: {
241240
__args: {
242241
object: {
@@ -252,8 +251,8 @@ export class GameStreamerService {
252251
},
253252
id: true,
254253
},
255-
} as any);
256-
const sessionId = (insertRes as any)?.insert_match_demo_sessions_one?.id;
254+
});
255+
const sessionId = insert_match_demo_sessions_one?.id;
257256
if (!sessionId) {
258257
throw new Error("failed to insert demo session row");
259258
}
@@ -268,7 +267,7 @@ export class GameStreamerService {
268267
},
269268
id: true,
270269
},
271-
} as any);
270+
});
272271

273272
const nodeId = await this.pickGpuNode(match.region);
274273

@@ -359,7 +358,7 @@ export class GameStreamerService {
359358
__args: { id: sessionId },
360359
id: true,
361360
},
362-
} as any);
361+
});
363362
}
364363

365364
public async demoControl(
@@ -423,7 +422,7 @@ export class GameStreamerService {
423422
}
424423

425424
private async findDemoSession(matchMapId: string, userSteamId: string) {
426-
const { match_demo_sessions } = (await this.hasura.query({
425+
const { match_demo_sessions } = await this.hasura.query({
427426
match_demo_sessions: {
428427
__args: {
429428
where: {
@@ -437,15 +436,8 @@ export class GameStreamerService {
437436
session_token: true,
438437
status: true,
439438
},
440-
} as any)) as any;
441-
return match_demo_sessions?.[0] as
442-
| {
443-
id: string;
444-
k8s_job_name: string;
445-
session_token: string;
446-
status: string;
447-
}
448-
| undefined;
439+
});
440+
return match_demo_sessions?.[0];
449441
}
450442

451443
public async pingDemoSession(matchMapId: string, userSteamId: string) {
@@ -460,7 +452,7 @@ export class GameStreamerService {
460452
},
461453
affected_rows: true,
462454
},
463-
} as any);
455+
});
464456
}
465457

466458
private async bumpDemoSessionActivity(sessionId: string) {
@@ -472,7 +464,7 @@ export class GameStreamerService {
472464
},
473465
id: true,
474466
},
475-
} as any);
467+
});
476468
}
477469

478470
public async validateDemoSessionAuth(
@@ -493,7 +485,7 @@ export class GameStreamerService {
493485
return null;
494486
}
495487

496-
const { match_demo_sessions } = (await this.hasura.query({
488+
const { match_demo_sessions } = await this.hasura.query({
497489
match_demo_sessions: {
498490
__args: {
499491
where: { id: { _eq: sessionId } },
@@ -504,7 +496,7 @@ export class GameStreamerService {
504496
match_map_id: true,
505497
session_token: true,
506498
},
507-
} as any)) as any;
499+
});
508500
const row = match_demo_sessions?.[0];
509501
if (!row?.session_token) return null;
510502

@@ -523,12 +515,12 @@ export class GameStreamerService {
523515
sessionId: string,
524516
body: GameStreamerStatusDto,
525517
) {
526-
const { match_demo_sessions_by_pk: current } = (await this.hasura.query({
518+
const { match_demo_sessions_by_pk: current } = await this.hasura.query({
527519
match_demo_sessions_by_pk: {
528520
__args: { id: sessionId },
529521
status_history: true,
530522
},
531-
} as any)) as any;
523+
});
532524

533525
if (!current) {
534526
this.logger.warn(
@@ -558,7 +550,7 @@ export class GameStreamerService {
558550
},
559551
id: true,
560552
},
561-
} as any);
553+
});
562554

563555
this.logger.log(
564556
`[demo ${sessionId}] status=${body.status}${body.error ? ` err=${body.error}` : ""}`,
@@ -626,7 +618,7 @@ export class GameStreamerService {
626618
public async reapIdleDemoSessions(idleSeconds = 60) {
627619
const threshold = new Date(Date.now() - idleSeconds * 1000).toISOString();
628620

629-
const { match_demo_sessions } = (await this.hasura.query({
621+
const { match_demo_sessions } = await this.hasura.query({
630622
match_demo_sessions: {
631623
__args: {
632624
where: {
@@ -637,7 +629,7 @@ export class GameStreamerService {
637629
k8s_job_name: true,
638630
last_activity_at: true,
639631
},
640-
} as any)) as any;
632+
});
641633

642634
for (const session of match_demo_sessions ?? []) {
643635
this.logger.log(
@@ -697,16 +689,16 @@ export class GameStreamerService {
697689
);
698690
if (allClusterIds.length === 0) return;
699691

700-
const { match_demo_sessions } = (await this.hasura.query({
692+
const { match_demo_sessions } = await this.hasura.query({
701693
match_demo_sessions: {
702694
__args: {
703695
where: { id: { _in: allClusterIds } },
704696
},
705697
id: true,
706698
},
707-
} as any)) as any;
699+
});
708700
const liveIds = new Set<string>(
709-
(match_demo_sessions ?? []).map((s: { id: string }) => s.id),
701+
(match_demo_sessions ?? []).map((s) => s.id),
710702
);
711703

712704
for (const sessionId of allClusterIds) {
@@ -1101,7 +1093,7 @@ export class GameStreamerService {
11011093
status: "booting",
11021094
status_history: [{ status: "booting", at: nowIso }],
11031095
last_status_at: "now()",
1104-
} as any,
1096+
},
11051097
},
11061098
id: true,
11071099
},
@@ -1145,7 +1137,7 @@ export class GameStreamerService {
11451137
}
11461138

11471139
public async reportStatus(matchId: string, body: GameStreamerStatusDto) {
1148-
const { match_streams } = (await this.hasura.query({
1140+
const { match_streams } = await this.hasura.query({
11491141
match_streams: {
11501142
__args: {
11511143
where: {
@@ -1156,7 +1148,7 @@ export class GameStreamerService {
11561148
},
11571149
status_history: true,
11581150
},
1159-
} as any)) as any;
1151+
});
11601152
const previous = Array.isArray(match_streams?.[0]?.status_history)
11611153
? (match_streams[0].status_history as unknown[])
11621154
: [];
@@ -1181,7 +1173,7 @@ export class GameStreamerService {
11811173
match_id: { _eq: matchId },
11821174
is_game_streamer: { _eq: true },
11831175
},
1184-
_set: setClause as any,
1176+
_set: setClause,
11851177
},
11861178
affected_rows: true,
11871179
},
@@ -1215,7 +1207,7 @@ export class GameStreamerService {
12151207
priority: 0,
12161208
is_game_streamer: true,
12171209
...setClause,
1218-
} as any,
1210+
},
12191211
},
12201212
id: true,
12211213
},

0 commit comments

Comments
 (0)