Skip to content

Commit

Permalink
Delete all but the latest cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-finley committed Aug 30, 2024
1 parent 4091618 commit 11c6892
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions queue_files/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ def run(event, context):
if dropbox_result.has_more:
publisher.publish(QUEUE_TOPIC_NAME, "Hi".encode("utf-8"))

# Delete all but the newest cursor
with conn.cursor() as cursor:
cursor.execute(
"""
DELETE FROM dropbox_cursors
WHERE dropbox_cursor NOT IN (
SELECT dropbox_cursor
FROM dropbox_cursors
ORDER BY created_at DESC
LIMIT 1
)
"""
)

conn.close()


Expand Down

0 comments on commit 11c6892

Please sign in to comment.