Skip to content

Commit

Permalink
added cleaning history older then 3 month
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Jul 16, 2024
1 parent 7cad0be commit 1d88808
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pepdbagent/modules/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,3 +1351,19 @@ def restore(
tag=tag,
user=user or namespace,
)

def clean_history(self, days: int = 90) -> None:
"""
Delete all history data that is older then 3 month, or specific number of days
:param days: number of days to keep history data
:return: None
"""

with Session(self._sa_engine) as session:
session.execute(
delete(HistoryProjects).where(
HistoryProjects.update_time < (datetime.datetime.now() - datetime.timedelta(days=days))
)
)
session.commit()

0 comments on commit 1d88808

Please sign in to comment.