From 9c81e9b509a71c98c979767bab55cff9fb0fbee3 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 22 Aug 2020 11:09:07 -0400 Subject: [PATCH] http-service: increase loot tracker retention to 90 days --- .../http/service/loottracker/LootTrackerService.java | 10 ++++++++-- http-service/src/main/resources/application.yaml | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerService.java b/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerService.java index 0cd75a0365..1a4ee1230f 100644 --- a/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerService.java +++ b/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerService.java @@ -33,6 +33,7 @@ import net.runelite.http.api.loottracker.LootAggregate; import net.runelite.http.api.loottracker.LootRecord; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.sql2o.Connection; @@ -75,11 +76,16 @@ public class LootTrackerService private static final String DELETE_LOOT_ACCOUNT_EVENTID = "DELETE FROM loottracker_kills WHERE accountId = :accountId AND eventId = :eventId"; private final Sql2o sql2o; + private final int historyDays; @Autowired - public LootTrackerService(@Qualifier("Runelite SQL2O") Sql2o sql2o) + public LootTrackerService( + @Qualifier("Runelite SQL2O") Sql2o sql2o, + @Value("${runelite.loottracker.history}") int historyDays + ) { this.sql2o = sql2o; + this.historyDays = historyDays; // Ensure necessary tables exist try (Connection con = sql2o.open()) @@ -197,7 +203,7 @@ public class LootTrackerService { try (Connection con = sql2o.open()) { - con.createQuery("delete from loottracker_kills where last_time < current_timestamp() - interval 30 day") + con.createQuery("delete from loottracker_kills where last_time < current_timestamp() - interval " + historyDays + " day") .executeUpdate(); } } diff --git a/http-service/src/main/resources/application.yaml b/http-service/src/main/resources/application.yaml index 4328ccfdc0..e3b8b07425 100644 --- a/http-service/src/main/resources/application.yaml +++ b/http-service/src/main/resources/application.yaml @@ -34,11 +34,13 @@ mongo: jndiName: java:comp/env/mongodb/runelite database: runelite -# Twitter client for feed runelite: + # Twitter client for feed twitter: consumerkey: secretkey: listid: 1185897074786742273 ge: + history: 90 # days + loottracker: history: 90 # days \ No newline at end of file