Skip to content

Commit 16f5c7c

Browse files
authored
Merge pull request #103 from marcodejongh/fix_shared_sync_6
lmao actually just forgot an await
2 parents 294b013 + 060a1f3 commit 16f5c7c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

app/api/internal/shared-sync/[board_name]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export async function GET(request: Request, { params }: { params: BoardRoutePara
2020
}
2121
console.log(`Passed auth for ${board_name}`);
2222

23-
const result = syncSharedData(board_name);
23+
const result = await syncSharedData(board_name);
2424

2525
return NextResponse.json({
2626
success: true,

app/lib/data-sync/aurora/shared-sync.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,25 +296,25 @@ async function updateSharedSyncs(
296296
}
297297
}
298298

299-
export async function getLastSharedSyncTimes(boardName: BoardName, tableNames = SHARED_SYNC_TABLES) {
299+
export async function getLastSharedSyncTimes(boardName: BoardName) {
300300
const sharedSyncsSchema = getTable('sharedSyncs', boardName);
301301

302302
const result = await db
303303
.select({
304304
table_name: sharedSyncsSchema.tableName,
305305
last_synchronized_at: sharedSyncsSchema.lastSynchronizedAt,
306306
})
307-
.from(sharedSyncsSchema)
308-
.where(inArray(sharedSyncsSchema.tableName, tableNames as unknown as Array<string>));
307+
.from(sharedSyncsSchema);
309308

310309
return result;
311310
}
312311

313312
export async function syncSharedData(
314313
board: BoardName,
315314
): Promise<Record<string, { synced: number }>> {
316-
const allSyncTimes = await getLastSharedSyncTimes(board, SHARED_SYNC_TABLES);
317-
315+
console.log('Entered sync shared data');
316+
const allSyncTimes = await getLastSharedSyncTimes(board);
317+
console.log('Fetched previous sync times');
318318
const syncParams: SyncOptions = {
319319
tables: [...SHARED_SYNC_TABLES],
320320
sharedSyncs: allSyncTimes.map((syncTime) => ({
@@ -326,6 +326,7 @@ export async function syncSharedData(
326326
const syncResults = await sharedSync(board, syncParams);
327327

328328
console.log(`Received ${syncResults.PUT.climbs.length} climbs and ${syncResults.PUT.climb_stats.length} climb_stats`);
329+
329330
return upsertAllSharedTableData(board, syncResults);
330331
}
331332

0 commit comments

Comments
 (0)