-
Notifications
You must be signed in to change notification settings - Fork 8
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 #53 from LCOGT/delete_old_observations
added task for deleting old observations
- Loading branch information
Showing
4 changed files
with
70 additions
and
1 deletion.
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
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,14 @@ | ||
import dramatiq | ||
import logging | ||
from datetime import datetime, timedelta | ||
|
||
from observation_portal.observations.models import Observation | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@dramatiq.actor() | ||
def delete_old_observations(): | ||
cutoff = datetime.utcnow() - timedelta(days=14) | ||
logger.info(f'Deleting CANCELED observations before cutoff date {cutoff}') | ||
Observation.delete_old_observations(cutoff) |
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