http-service: increase ge history retention to 90 days

This commit is contained in:
Adam
2020-02-10 17:59:09 -05:00
parent 8137fd87c2
commit 9cf95ef324
2 changed files with 11 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ import java.util.Collection;
import net.runelite.http.api.ge.GrandExchangeTrade; import net.runelite.http.api.ge.GrandExchangeTrade;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.sql2o.Connection; import org.sql2o.Connection;
@@ -51,11 +52,16 @@ public class GrandExchangeService
") ENGINE=InnoDB;"; ") ENGINE=InnoDB;";
private final Sql2o sql2o; private final Sql2o sql2o;
private final int historyDays;
@Autowired @Autowired
public GrandExchangeService(@Qualifier("Runelite SQL2O") Sql2o sql2o) public GrandExchangeService(
@Qualifier("Runelite SQL2O") Sql2o sql2o,
@Value("${runelite.ge.history}") int historyDays
)
{ {
this.sql2o = sql2o; this.sql2o = sql2o;
this.historyDays = historyDays;
// Ensure necessary tables exist // Ensure necessary tables exist
try (Connection con = sql2o.open()) try (Connection con = sql2o.open())
@@ -106,7 +112,7 @@ public class GrandExchangeService
{ {
try (Connection con = sql2o.open()) try (Connection con = sql2o.open())
{ {
con.createQuery("delete from ge_trades where time < current_timestamp - interval 1 month") con.createQuery("delete from ge_trades where time < current_timestamp - interval " + historyDays + " day")
.executeUpdate(); .executeUpdate();
} }
} }

View File

@@ -39,4 +39,6 @@ runelite:
twitter: twitter:
consumerkey: consumerkey:
secretkey: secretkey:
listid: 1185897074786742273 listid: 1185897074786742273
ge:
history: 90 # days