@@ -35,6 +35,8 @@ export const fetchAndProcessEventsPageByPage = async (
3535 nextSyncToken : string | undefined ;
3636 baseEventMap : Map < string , ObjectId > ;
3737} > => {
38+ const start = Date . now ( ) ;
39+
3840 try {
3941 let nextPageToken : string | undefined = undefined ;
4042 let finalNextSyncToken : string | undefined = undefined ;
@@ -47,11 +49,12 @@ export const fetchAndProcessEventsPageByPage = async (
4749 `${ passIdentifier } : Fetching events for ${ calendarId } . Params: ${ JSON . stringify ( gcalApiParams ) } ` ,
4850 ) ;
4951
52+ const maxResults = gcalApiParams . maxResults || 1000 ;
5053 do {
5154 const params : gParamsImportAllEvents = {
5255 calendarId,
5356 pageToken : nextPageToken ,
54- maxResults : 250 , // Consider making configurable
57+ maxResults,
5558 ...gcalApiParams , // Spread specific parameters like singleEvents
5659 } ;
5760
@@ -117,8 +120,13 @@ export const fetchAndProcessEventsPageByPage = async (
117120 }
118121 } while ( nextPageToken !== undefined ) ;
119122
120- logger . info (
121- `${ passIdentifier } completed for ${ calendarId } . Processed ${ totalProcessedApi } API events. Saved ${ totalSaved } total events.` ,
123+ logSummary (
124+ passIdentifier ,
125+ calendarId ,
126+ maxResults ,
127+ totalProcessedApi ,
128+ totalSaved ,
129+ start ,
122130 ) ;
123131
124132 return {
@@ -134,3 +142,23 @@ export const fetchAndProcessEventsPageByPage = async (
134142 throw err ;
135143 }
136144} ;
145+
146+ const logSummary = (
147+ passIdentifier : string ,
148+ calendarId : string ,
149+ maxResults : number ,
150+ totalProcessedApi : number ,
151+ totalSaved : number ,
152+ start : number ,
153+ ) => {
154+ const end = Date . now ( ) ;
155+ const seconds = ( end - start ) / 1000 ;
156+ logger . info (
157+ `${ passIdentifier } completed for ${ calendarId } .
158+ Max results / page: ${ maxResults }
159+ Processed Gcal events: ${ totalProcessedApi }
160+ Saved Compass events: ${ totalSaved }
161+ Duration: ${ seconds . toFixed ( 2 ) } s
162+ ` ,
163+ ) ;
164+ } ;
0 commit comments