@@ -50,7 +50,7 @@ async function fetchWakApiHeartbeats(
5050 headers : any ,
5151 startDate : Date ,
5252 endDate : Date ,
53- userId : string ,
53+ userId : string
5454) {
5555 const today = new Date ( ) ;
5656 const adjustedEndDate = new Date ( ) ;
@@ -81,12 +81,12 @@ async function fetchWakApiHeartbeats(
8181 {
8282 params : { date : dateStr } ,
8383 headers,
84- } ,
84+ }
8585 ) ;
8686
8787 if ( heartbeatsResponse ?. data && heartbeatsResponse . data . length > 0 ) {
8888 const heartbeats = heartbeatsResponse . data . map ( ( h ) =>
89- processWakaApiHeartbeat ( h , userId ) ,
89+ processWakaApiHeartbeat ( h , userId )
9090 ) ;
9191
9292 heartbeatsByDate . set ( dateStr , heartbeats ) ;
@@ -100,7 +100,7 @@ export async function prepareWakApiData(
100100 apiKey : string ,
101101 instanceUrl : string ,
102102 userId : string ,
103- job ?: ImportJob ,
103+ job ?: ImportJob
104104) : Promise < Map < string , any [ ] > > {
105105 if ( job ) {
106106 updateJob ( job , {
@@ -126,7 +126,7 @@ export async function prepareWakApiData(
126126
127127 if ( ! allTimeResponse ?. data ?. range ) {
128128 throw new Error (
129- `Failed to fetch activity date range from WakAPI for user ${ userId } ` ,
129+ `Failed to fetch activity date range from WakAPI for user ${ userId } `
130130 ) ;
131131 }
132132
@@ -145,7 +145,7 @@ export async function prepareWakApiData(
145145 headers ,
146146 startDate ,
147147 endDate ,
148- userId ,
148+ userId
149149 ) ;
150150
151151 return heartbeatsByDate ;
@@ -154,14 +154,14 @@ export async function prepareWakApiData(
154154export async function handleWakApiSequentialImport (
155155 heartbeatsByDate : Map < string , any [ ] > ,
156156 userId : string ,
157- job : ImportJob ,
157+ job : ImportJob
158158) : Promise < { success : boolean ; imported ?: number ; message ?: string } > {
159159 try {
160160 handleLog ( `[wakapi] Starting WakAPI sequential import for user ${ userId } ` ) ;
161161
162162 const datesWithData = Array . from ( heartbeatsByDate . keys ( ) ) ;
163163 handleLog (
164- `[wakapi] Processing ${ datesWithData . length } days of data sequentially` ,
164+ `[wakapi] Processing ${ datesWithData . length } days of data sequentially`
165165 ) ;
166166
167167 updateJob ( job , {
@@ -170,14 +170,12 @@ export async function handleWakApiSequentialImport(
170170 total : datesWithData . length ,
171171 } ) ;
172172
173- let totalHeartbeats = 0 ;
174173 for ( let i = 0 ; i < datesWithData . length ; i ++ ) {
175174 const dateStr = datesWithData [ i ] ;
176175 const heartbeats = heartbeatsByDate . get ( dateStr ) ;
177176
178177 if ( heartbeats && heartbeats . length > 0 ) {
179178 await processHeartbeatsByDate ( userId , heartbeats ) ;
180- totalHeartbeats += heartbeats . length ;
181179 }
182180
183181 updateJob ( job , {
@@ -193,13 +191,13 @@ export async function handleWakApiSequentialImport(
193191 } ) ;
194192
195193 handleLog (
196- `[wakapi] Successfully imported ${ totalHeartbeats } heartbeats from WakAPI` ,
194+ `[wakapi] Successfully imported ${ datesWithData . length } days from WakAPI`
197195 ) ;
198196
199197 return {
200198 success : true ,
201- imported : totalHeartbeats ,
202- message : `Successfully imported ${ totalHeartbeats } heartbeats ` ,
199+ imported : datesWithData . length ,
200+ message : `Successfully imported ${ datesWithData . length } days ` ,
203201 } ;
204202 } catch ( error : any ) {
205203 const errorMessage = error instanceof Error ? error . message : String ( error ) ;
@@ -209,21 +207,21 @@ export async function handleWakApiSequentialImport(
209207 } ) ;
210208
211209 handleLog (
212- `[wakapi] WakAPI import failed for user ${ userId } : ${ errorMessage } ` ,
210+ `[wakapi] WakAPI import failed for user ${ userId } : ${ errorMessage } `
213211 ) ;
214212
215213 throw handleApiError (
216214 69 ,
217215 `WakAPI import failed for user ${ userId } : ${ errorMessage } ` ,
218- "Failed to import data from WakAPI. Please check your API key and try again." ,
216+ "Failed to import data from WakAPI. Please check your API key and try again."
219217 ) ;
220218 }
221219}
222220
223221export async function handleWakApiDateChunk (
224222 dates : string [ ] ,
225223 userId : string ,
226- heartbeatsByDate : Record < string , any [ ] > ,
224+ heartbeatsByDate : Record < string , any [ ] >
227225) : Promise < { success : boolean ; processed : number } > {
228226 try {
229227 let totalProcessed = 0 ;
@@ -242,7 +240,7 @@ export async function handleWakApiDateChunk(
242240 } ;
243241 } catch ( error ) {
244242 handleLog (
245- `[wakapi] Failed to process date chunk for user ${ userId } : ${ error } ` ,
243+ `[wakapi] Failed to process date chunk for user ${ userId } : ${ error } `
246244 ) ;
247245 throw error ;
248246 }
@@ -252,7 +250,7 @@ export async function handleWakApiImport(
252250 apiKey : string ,
253251 instanceUrl : string ,
254252 userId : string ,
255- existingJob ?: ImportJob ,
253+ existingJob ?: ImportJob
256254) : Promise < { success : boolean ; imported ?: number ; message ?: string } > {
257255 const job : ImportJob = existingJob || {
258256 id : randomUUID ( ) ,
@@ -279,7 +277,7 @@ export async function handleWakApiImport(
279277 const heartbeatsByDate = await prepareWakApiData (
280278 apiKey ,
281279 instanceUrl ,
282- userId ,
280+ userId
283281 ) ;
284282
285283 return await handleWakApiSequentialImport ( heartbeatsByDate , userId , job ) ;
@@ -291,13 +289,13 @@ export async function handleWakApiImport(
291289 } ) ;
292290
293291 handleLog (
294- `[wakapi] WakAPI import failed for user ${ userId } : ${ errorMessage } ` ,
292+ `[wakapi] WakAPI import failed for user ${ userId } : ${ errorMessage } `
295293 ) ;
296294
297295 throw handleApiError (
298296 69 ,
299297 `WakAPI import failed for user ${ userId } : ${ errorMessage } ` ,
300- "Failed to import data from WakAPI. Please check your API key and try again." ,
298+ "Failed to import data from WakAPI. Please check your API key and try again."
301299 ) ;
302300 }
303301}
0 commit comments