Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repocleaner: none_kept: use creation time #2455

Merged
merged 1 commit into from
Oct 21, 2024
Merged
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
21 changes: 11 additions & 10 deletions Framework/script/RepoCleaner/qcrepocleaner/rules/none_kept.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from datetime import datetime
from datetime import timedelta
import logging
from typing import Dict

from qcrepocleaner.Ccdb import Ccdb, ObjectVersion

from qcrepocleaner import policies_utils
from typing import Dict, List

logger = logging # default logger

Expand All @@ -31,22 +29,25 @@ def process(ccdb: Ccdb, object_path: str, delay: int, from_timestamp: int, to_t
deletion_list: List[ObjectVersion] = []

for v in versions:
if v.validFromAsDt < datetime.now() - timedelta(minutes=delay): # grace period
logger.debug(f"not in the grace period")
logger.debug(f"Processing version {v}")
if policies_utils.in_grace_period(v, delay):
logger.debug(f" in grace period, skip this version")
preservation_list.append(v)
else:
logger.debug(f" not in the grace period")
if from_timestamp < v.validFrom < to_timestamp: # in the allowed period
logger.debug(f"in the allowed period (from,to), we delete {v}")
logger.debug(f" in the allowed period (from,to), we delete it")
deletion_list.append(v)
ccdb.deleteVersion(v)
continue
preservation_list.append(v)

logger.debug("deleted : ")
for v in deletion_list:
logger.debug(f" {v} - {v.validFrom}")
logger.debug(f" {v}")

logger.debug("preserved : ")
for v in preservation_list:
logger.debug(f" {v} - {v.validFrom}")
logger.debug(f" {v}")

return {"deleted": len(deletion_list), "preserved": len(preservation_list), "updated": 0}

Expand Down
Loading