Skip to content

Commit 9862ee8

Browse files
committed
Add count-speakers-without-details
1 parent db0a3e0 commit 9862ee8

File tree

2 files changed

+58
-20
lines changed

2 files changed

+58
-20
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env tsx
2+
3+
import { join } from "node:path"
4+
import { readFile } from "node:fs/promises"
5+
6+
import type { SchedSpeaker } from "@/app/conf/_api/sched-types"
7+
;(async function main() {
8+
try {
9+
const speakersFilePath = join(import.meta.dirname, "speakers.json")
10+
11+
console.log("Reading speakers.json...")
12+
13+
const speakersData = await readFile(speakersFilePath, "utf-8")
14+
const speakers: SchedSpeaker[] = JSON.parse(speakersData)
15+
16+
const speakersWithoutDetails = speakers.filter(
17+
speaker => !speaker["~syncedDetailsAt"],
18+
)
19+
20+
console.log(`Total speakers: ${speakers.length}`)
21+
console.log(
22+
`Speakers without ~syncedDetailsAt: ${speakersWithoutDetails.length}`,
23+
)
24+
25+
if (speakersWithoutDetails.length > 0) {
26+
console.log("\nSpeakers missing details:")
27+
for (const speaker of speakersWithoutDetails) {
28+
console.log(`- ${speaker.username} (${speaker.name || "No name"})`)
29+
}
30+
}
31+
} catch (error) {
32+
console.error("Error:", error)
33+
process.exit(1)
34+
}
35+
})()

scripts/sync-sched/sync.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,47 @@ import type { SchedSpeaker } from "@/app/conf/_api/sched-types"
2121
* - one request for the list of speakers with partial details
2222
* - and N requests for the full details of each speaker
2323
*/
24-
const SPEAKER_DETAILS_REQUEST_QUOTA = 10
24+
const DEFAULT_SPEAKER_DETAILS_REQUEST_QUOTA = 10
2525

2626
const PRINT_UNCHANGED = false
2727

28-
const options = {
29-
year: {
30-
type: "string" as const,
31-
short: "y",
32-
},
33-
help: {
34-
type: "boolean" as const,
35-
short: "h",
36-
},
37-
}
38-
3928
const unsafeKeys = Object.keys as <T extends object>(obj: T) => Array<keyof T>
4029

4130
;(async function main() {
4231
try {
43-
const { values } = parseArgs({ options })
32+
const { values } = parseArgs({
33+
options: {
34+
year: {
35+
type: "string",
36+
short: "y",
37+
},
38+
quota: {
39+
type: "string",
40+
short: "q",
41+
},
42+
help: {
43+
type: "boolean",
44+
short: "h",
45+
},
46+
},
47+
})
4448

4549
if (values.help) {
4650
help()
4751
process.exit(0)
4852
}
4953

5054
const year = parseInt(values.year || new Date().getFullYear().toString())
55+
const quota = parseInt(
56+
values.quota || DEFAULT_SPEAKER_DETAILS_REQUEST_QUOTA.toString(),
57+
)
5158

5259
console.log(`Syncing schedule for year: ${year}`)
5360

5461
const token = process.env[`SCHED_ACCESS_TOKEN_${year}`]
5562
assert(token, `SCHED_ACCESS_TOKEN_${year} is not set`)
5663

57-
await sync(year, token)
64+
await sync(year, quota, token)
5865
} catch (error) {
5966
if (error instanceof Error && error.message.includes("Unknown option")) {
6067
console.error(`Error: ${error.message}`)
@@ -65,7 +72,7 @@ const unsafeKeys = Object.keys as <T extends object>(obj: T) => Array<keyof T>
6572
}
6673
})()
6774

68-
async function sync(year: number, token: string) {
75+
async function sync(year: number, detailsRequestsQuota: number, token: string) {
6976
const apiUrl = {
7077
2023: "https://graphqlconf23.sched.com/api",
7178
2024: "https://graphqlconf2024.sched.com/api",
@@ -106,11 +113,7 @@ async function sync(year: number, token: string) {
106113
{ merge: true },
107114
)
108115

109-
await updateSpeakerDetails(
110-
ctx,
111-
speakerComparison,
112-
SPEAKER_DETAILS_REQUEST_QUOTA,
113-
)
116+
await updateSpeakerDetails(ctx, speakerComparison, detailsRequestsQuota)
114117

115118
printComparison(speakerComparison, "speakers", "username", {
116119
// we don't remove speakers

0 commit comments

Comments
 (0)