Skip to content

Commit 9d156c6

Browse files
committed
chore: wrap each CH function to see failures and sync helpful threads to algolia
1 parent ce9d266 commit 9d156c6

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/app/(frontend)/api/sync-ch/route.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@ export const maxDuration = 300 // 5 mins (max on vercel pro plan)
99
export const dynamic = 'force-dynamic'
1010

1111
export async function GET(): Promise<NextResponse> {
12-
await clearDuplicateThreads()
13-
await fetchDiscord()
14-
await fetchGitHub()
15-
await syncToAlgolia()
12+
const tasks = [
13+
{ name: 'clearDuplicateThreads', fn: clearDuplicateThreads },
14+
{ name: 'fetchDiscord', fn: fetchDiscord },
15+
{ name: 'fetchGitHub', fn: fetchGitHub },
16+
{ name: 'syncToAlgolia', fn: syncToAlgolia },
17+
]
18+
19+
// Execute each task, catch errors, and log them
20+
for (const { name, fn } of tasks) {
21+
try {
22+
await fn()
23+
} catch (error) {
24+
console.error(`Error in ${name}:`, error)
25+
}
26+
}
1627

1728
return NextResponse.json((JSON.stringify({ success: true }), { status: 200 }))
1829
}

src/collections/CommunityHelp/updateAlgolia.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const updateAlgolia = async (id: string, helpful: boolean): Promise<void>
1717
objectID: id,
1818
},
1919
{
20-
createIfNotExists: false,
20+
createIfNotExists: true,
2121
},
2222
)
2323
.then(() => {

0 commit comments

Comments
 (0)