Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def connect_to_db():

async def purge_old_nodes(age_days=180, batch_size=1000):
"""
Purge nodes from the 'nodes' collection that are older than the
Purge nodes from the 'node' collection that are older than the
specified number of days.

Args:
Expand All @@ -60,7 +60,7 @@ async def purge_old_nodes(age_days=180, batch_size=1000):
"""
date_end = datetime.datetime.today() - datetime.timedelta(days=age_days)
db = connect_to_db()
nodes = db["nodes"].find({
nodes = db["node"].find({
"created": {"$lt": date_end}
})
# We need to delete node in chunks of {batch_size}
Expand All @@ -71,11 +71,11 @@ async def purge_old_nodes(age_days=180, batch_size=1000):
del_batch.append(node["_id"])
if len(del_batch) == batch_size:
deleted += len(del_batch)
purge_ids(db, "nodes", del_batch)
purge_ids(db, "node", del_batch)
del_batch = []
if del_batch:
deleted += len(del_batch)
purge_ids(db, "nodes", del_batch)
purge_ids(db, "node", del_batch)
db = {
'response': 'ok',
'deleted': deleted,
Expand Down