Skip to content

Commit

Permalink
These expire-datasets changes were somehow missing
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-uva committed Feb 9, 2022
1 parent 1e89883 commit 1d64408
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/workers/expire_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def work(self):
# and now find datasets that have their expiration date set
# individually
cutoff = int(time.time())
datasets += self.db.fetchall("SELECT key FROM datasets WHERE parameters::json->>'expires-after' IS NOT NULL AND (parameters::json->>'expires-after')::int > %s", (cutoff,))
datasets += self.db.fetchall("SELECT key FROM datasets WHERE parameters::json->>'expires-after' IS NOT NULL AND (parameters::json->>'expires-after')::int < %s", (cutoff,))

# we instantiate the dataset, because its delete() method does all
# the work (e.g. deleting child datasets) for us
Expand Down
3 changes: 3 additions & 0 deletions common/lib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def __init__(self, parameters={}, key=None, job=None, data=None, db=None, parent
self.parameters = json.loads(self.data["parameters"])
self.is_new = False
else:
if hasattr(config, "EXPIRE_DATASETS") and config.EXPIRE_DATASETS and not parent:
parameters["expires-after"] = int(time.time() + config.EXPIRE_DATASETS)

self.data = {
"key": self.key,
"query": self.get_label(parameters, default=type),
Expand Down

0 comments on commit 1d64408

Please sign in to comment.