Skip to content

Commit

Permalink
feat: removing delete-status-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericosta-dev committed Oct 16, 2024
1 parent 400555d commit ee2372b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
4 changes: 0 additions & 4 deletions connect/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@


app.conf.beat_schedule = {
"delete-status-logs": {
"task": "connect.common.tasks.delete_status_logs",
"schedule": schedules.crontab(hour="22", minute=0),
},
"check-organization-free-plan": {
"task": "connect.common.tasks.check_organization_free_plan",
"schedule": schedules.crontab(minute="*/6"),
Expand Down
25 changes: 0 additions & 25 deletions connect/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,31 +362,6 @@ def capture_invoice():
# add send email


@app.task()
def delete_status_logs():
BATCH_SIZE = 5000
logs = LogService.objects.filter(
created_at__lt=timezone.now().replace(hour=0, minute=0, second=0, microsecond=0)
- timezone.timedelta(days=10)
)

num_updated = 0
max_id = -1
while True:
batch = list(logs.filter(id__gt=max_id).order_by("id")[:BATCH_SIZE])

if not batch:
break

max_id = batch[-1].id
with transaction.atomic():
for log in batch:
log.delete()

num_updated += len(batch)
print(f" > deleted {num_updated} status logs")


@app.task(
name="update_suspend_project",
autoretry_for=(_InactiveRpcError, Exception),
Expand Down

0 comments on commit ee2372b

Please sign in to comment.