This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from Amsterdam/feature/seperate-continuous-ag…
…gregate-removal Separated aggregation removal
- Loading branch information
Showing
4 changed files
with
66 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/continuousaggregate/management/commands/remove_aggregate_cmsa15min.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
from datetime import date | ||
|
||
from django.core.management.base import BaseCommand | ||
from django.db import connection, transaction | ||
|
||
from continuousaggregate.models import Cmsa15Min | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@transaction.atomic | ||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument('--since', type=date.fromisoformat) | ||
|
||
def handle(self, *args, **options): | ||
since = options['since'] | ||
|
||
since_log = '' | ||
if since: | ||
q = Cmsa15Min.objects.filter(timestamp_rounded__gt=since) | ||
since_log = since | ||
else: | ||
q = Cmsa15Min.objects.all() | ||
|
||
self.stdout.write(f"Start deleting records in aggregation table {Cmsa15Min._meta.db_table} since {since_log}") | ||
q.delete() | ||
self.stdout.write(f"Finished deleting records in aggregation table {Cmsa15Min._meta.db_table} since {since_log}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters