feature/Tweak the default value of retain_archive_metrics_days

This commit is contained in:
Marko Milić 2022-11-21 11:46:34 +01:00
parent ffc91866be
commit 0331ce65c8
2 changed files with 7 additions and 2 deletions

View File

@ -1207,7 +1207,8 @@ user_account_validated_redirect_url =
user_account_is_validated = false
# Defines the number of days we keep rows in the table "MetricsArchive"
retain_archive_metrics_days = 365
# default value is 3 years
retain_archive_metrics_days = 1095
# Defines the number of days we keep rows in the table "Metric" former "MappedMetric"
retain_metrics_days = 60

View File

@ -61,7 +61,11 @@ object MetricsArchiveScheduler extends MdcLoggable {
def deleteOutdatedRowsFromMetricsArchive() = {
val currentTime = new Date()
val days = APIUtil.getPropsAsLongValue("retain_archive_metrics_days", 365)
val defaultValue : Int = 365 * 3
val days = APIUtil.getPropsAsLongValue("retain_archive_metrics_days", defaultValue) match {
case days if days > 364 => days
case _ => 365
}
val oneYearAgo: Date = new Date(currentTime.getTime - (oneDayInMillis * days))
// Delete the outdated rows from the table "MetricsArchive"
MetricsArchive.bulkDelete_!!(By_<=(MetricsArchive.date, oneYearAgo))