We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5ba1df2 commit 648d187Copy full SHA for 648d187
1 file changed
app/api/cron/sync-health/route.ts
@@ -157,9 +157,16 @@ export async function GET(request: Request) {
157
}
158
159
160
- // Archived transition (previously not archived → now archived)
+ // Archived transition — only fire once, even if prevSnapshot is absent
161
const wasArchived = prevSnapshot?.archived ?? false;
162
- if (!wasArchived && ghData.archived) {
+ const { count: existingArchiveCount } = ghData.archived
163
+ ? await db
164
+ .from("tool_events")
165
+ .select("id", { count: "exact", head: true })
166
+ .eq("tool_id", tool.id)
167
+ .eq("type", "archived_detected")
168
+ : { count: 0 };
169
+ if (!wasArchived && ghData.archived && !existingArchiveCount) {
170
const { error: eventError } = await db.from("tool_events").insert({
171
tool_id: tool.id,
172
type: "archived_detected",
0 commit comments