@@ -21,40 +21,47 @@ import type { SchedSpeaker } from "@/app/conf/_api/sched-types"
21
21
* - one request for the list of speakers with partial details
22
22
* - and N requests for the full details of each speaker
23
23
*/
24
- const SPEAKER_DETAILS_REQUEST_QUOTA = 10
24
+ const DEFAULT_SPEAKER_DETAILS_REQUEST_QUOTA = 10
25
25
26
26
const PRINT_UNCHANGED = false
27
27
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
-
39
28
const unsafeKeys = Object . keys as < T extends object > ( obj : T ) => Array < keyof T >
40
29
41
30
; ( async function main ( ) {
42
31
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
+ } )
44
48
45
49
if ( values . help ) {
46
50
help ( )
47
51
process . exit ( 0 )
48
52
}
49
53
50
54
const year = parseInt ( values . year || new Date ( ) . getFullYear ( ) . toString ( ) )
55
+ const quota = parseInt (
56
+ values . quota || DEFAULT_SPEAKER_DETAILS_REQUEST_QUOTA . toString ( ) ,
57
+ )
51
58
52
59
console . log ( `Syncing schedule for year: ${ year } ` )
53
60
54
61
const token = process . env [ `SCHED_ACCESS_TOKEN_${ year } ` ]
55
62
assert ( token , `SCHED_ACCESS_TOKEN_${ year } is not set` )
56
63
57
- await sync ( year , token )
64
+ await sync ( year , quota , token )
58
65
} catch ( error ) {
59
66
if ( error instanceof Error && error . message . includes ( "Unknown option" ) ) {
60
67
console . error ( `Error: ${ error . message } ` )
@@ -65,7 +72,7 @@ const unsafeKeys = Object.keys as <T extends object>(obj: T) => Array<keyof T>
65
72
}
66
73
} ) ( )
67
74
68
- async function sync ( year : number , token : string ) {
75
+ async function sync ( year : number , detailsRequestsQuota : number , token : string ) {
69
76
const apiUrl = {
70
77
2023 : "https://graphqlconf23.sched.com/api" ,
71
78
2024 : "https://graphqlconf2024.sched.com/api" ,
@@ -106,11 +113,7 @@ async function sync(year: number, token: string) {
106
113
{ merge : true } ,
107
114
)
108
115
109
- await updateSpeakerDetails (
110
- ctx ,
111
- speakerComparison ,
112
- SPEAKER_DETAILS_REQUEST_QUOTA ,
113
- )
116
+ await updateSpeakerDetails ( ctx , speakerComparison , detailsRequestsQuota )
114
117
115
118
printComparison ( speakerComparison , "speakers" , "username" , {
116
119
// we don't remove speakers
0 commit comments