Skip to content

Commit c748f4f

Browse files
dongzhang84claude
andcommitted
debug: add logging to refresh route and refresh-opportunities lib
Log user id/email, keywords, subreddits, match counts, and duplicate count to help diagnose Scan Now returning no new opportunities. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent db4b917 commit c748f4f

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

app/api/opportunities/refresh/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export async function POST() {
1212
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
1313
}
1414

15+
console.log(`[refresh] Triggered by user: ${user.id} (${user.email})`)
16+
1517
try {
1618
const opportunitiesSaved = await refreshOpportunitiesForUser(user.id)
1719
return NextResponse.json({ success: true, opportunitiesSaved })

lib/refresh-opportunities.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export async function refreshOpportunitiesForUser(userId: string): Promise<numbe
4646
return 0
4747
}
4848

49+
console.log(`[refresh] User ${userId} — keywords: [${profile.keywords.join(', ')}]`)
50+
console.log(`[refresh] User ${userId} — subreddits: [${profile.subreddits.join(', ')}]`)
51+
4952
// Fetch Reddit posts for each of the user's subreddits
5053
const redditPosts: NormalizedPost[] = []
5154
await Promise.all(
@@ -130,6 +133,7 @@ export async function refreshOpportunitiesForUser(userId: string): Promise<numbe
130133
skipDuplicates: true,
131134
})
132135

133-
console.log(`[refresh] User ${userId} — saved ${result.count} new opportunity(ies)`)
136+
const duplicates = scored.length - result.count
137+
console.log(`[refresh] User ${userId} — saved ${result.count} new opportunity(ies) (${duplicates} skipped as duplicates)`)
134138
return result.count
135139
}

0 commit comments

Comments
 (0)