-
Notifications
You must be signed in to change notification settings - Fork 24
feat(history): implement automatic history purge logic #992
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
3ecfc98
7397bf4
c7fdcdb
8ea41d1
27f2151
76aaba7
0218852
faaf16f
371ecc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,6 +158,37 @@ ClassMethod DeleteHistory(ByRef filter) As %Integer | |
| quit rs.%ROWCOUNT | ||
| } | ||
|
|
||
| /// Automatically purge old history based on retention settings | ||
| ClassMethod AutPurgeOldHistory() | ||
| { | ||
| if ..GetHistoryLastPurge() = +$horolog { | ||
| quit | ||
| } | ||
| set retainDays = ##class(%IPM.Repo.UniversalSettings).GetHistoryRetain() | ||
| quit:(+retainDays <=0) | ||
|
||
|
|
||
| set cutoffDate = $system.SQL.Functions.DATEADD("d", -retainDays, +$horolog) | ||
| set filter("TimeStart") = "<='" _cutoffDate_"'" | ||
| set tSC = ..DeleteHistoryGlobally(.filter, 0) | ||
isc-dchui marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| do ..SetHistoryLastPurge() | ||
| } | ||
|
|
||
| ClassMethod SetHistoryLastPurge(indx As %String = {##class(%IPM.Repo.UniversalSettings).#HistoryRetain}) | ||
isc-dchui marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| new $namespace | ||
| return:(indx="") "" | ||
| set $namespace = "%SYS" | ||
| set ^IPM.settings(indx,"lastPurge") = +$horolog | ||
| } | ||
|
|
||
| ClassMethod GetHistoryLastPurge(indx As %String = {##class(%IPM.Repo.UniversalSettings).#HistoryRetain}) As %Integer | ||
| { | ||
| new $namespace | ||
| return:(indx="") "" | ||
| set $namespace = "%SYS" | ||
| return $get(^IPM.settings(indx,"lastPurge")) | ||
| } | ||
|
|
||
| ClassMethod DeleteHistoryGlobally( | ||
| ByRef filter, | ||
| verbose As %Boolean = 0) As %Integer | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.