File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
src/routes/api/delete-old-trash Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ name: Delete Old Trash Notes
22on :
33 schedule :
44 - cron : ' 0 0 * * *' # Runs daily at midnight UTC
5+ workflow_dispatch : # Allows manual triggering
56
67jobs :
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
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments