Skip to content

Commit 550f6ac

Browse files
committed
Fix delete-old-trash workflow Try-1
1 parent c18d3d2 commit 550f6ac

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

.github/workflows/delete-old-trash.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ name: Delete Old Trash Notes
22
on:
33
schedule:
44
- cron: '0 0 * * *' # Runs daily at midnight UTC
5+
workflow_dispatch: # Allows manual triggering
56

67
jobs:
78
cleanup:
89
runs-on: ubuntu-latest
910
steps:
1011
- name: Call Delete API
11-
run: curl -X GET https://https://keep-clone-kappa.vercel.app/api/delete-old-trash
12+
run: curl -X GET https://keep-clone-kappa.vercel.app/api/delete-old-trash

src/routes/api/delete-old-trash/+server.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ export async function GET() {
66
twoWeeksAgo.setDate(twoWeeksAgo.getDate() - 14);
77

88
console.log(`Deleting notes trashed before ${twoWeeksAgo.toISOString()}`);
9+
console.log('Date filter:', twoWeeksAgo.toISOString());
10+
11+
const testQuery = await supabase
12+
.from('notes')
13+
.select('count')
14+
.lte('created_at', twoWeeksAgo.toISOString())
15+
.eq('trashed', true);
16+
17+
console.log('Matching records count:', testQuery.data);
18+
console.log('Query check:', testQuery.error ? 'Error: ' + testQuery.error.message : 'OK');
919

1020
const { data, error } = await supabase
11-
.from('notes')
21+
.from('notes') // Use 'notes' as the table name
1222
.delete()
13-
.lte('updated_at', twoWeeksAgo.toISOString())
23+
.lte('created_at', twoWeeksAgo.toISOString())
1424
.eq('trashed', true)
1525
.select(); // Add this to get count of deleted items
1626

@@ -25,4 +35,4 @@ export async function GET() {
2535
message: 'Old trashed notes deleted',
2636
count: data?.length ?? 0
2737
}, { status: 200 });
28-
}
38+
}

0 commit comments

Comments
 (0)