Merge pull request #7834 from deathbeam/add-loot-tracker-offset

Add offset to loot tracker API
This commit is contained in:
Adam
2019-02-12 18:01:14 -05:00
committed by GitHub
2 changed files with 5 additions and 4 deletions

View File

@@ -66,7 +66,7 @@ public class LootTrackerController
} }
@RequestMapping @RequestMapping
public Collection<LootRecord> getLootRecords(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "count", defaultValue = "1024") int count) throws IOException public Collection<LootRecord> getLootRecords(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "count", defaultValue = "1024") int count, @RequestParam(value = "start", defaultValue = "0") int start) throws IOException
{ {
SessionEntry e = auth.handle(request, response); SessionEntry e = auth.handle(request, response);
if (e == null) if (e == null)
@@ -75,7 +75,7 @@ public class LootTrackerController
return null; return null;
} }
return service.get(e.getUser(), count); return service.get(e.getUser(), count, start);
} }
@DeleteMapping @DeleteMapping

View File

@@ -66,7 +66,7 @@ public class LootTrackerService
private static final String INSERT_KILL_QUERY = "INSERT INTO kills (accountId, type, eventId) VALUES (:accountId, :type, :eventId)"; private static final String INSERT_KILL_QUERY = "INSERT INTO kills (accountId, type, eventId) VALUES (:accountId, :type, :eventId)";
private static final String INSERT_DROP_QUERY = "INSERT INTO drops (killId, itemId, itemQuantity) VALUES (LAST_INSERT_ID(), :itemId, :itemQuantity)"; private static final String INSERT_DROP_QUERY = "INSERT INTO drops (killId, itemId, itemQuantity) VALUES (LAST_INSERT_ID(), :itemId, :itemQuantity)";
private static final String SELECT_LOOT_QUERY = "SELECT killId,time,type,eventId,itemId,itemQuantity FROM kills JOIN drops ON drops.killId = kills.id WHERE accountId = :accountId ORDER BY TIME DESC LIMIT :limit"; private static final String SELECT_LOOT_QUERY = "SELECT killId,time,type,eventId,itemId,itemQuantity FROM kills JOIN drops ON drops.killId = kills.id WHERE accountId = :accountId ORDER BY TIME DESC LIMIT :limit OFFSET :offset";
private static final String DELETE_LOOT_ACCOUNT = "DELETE FROM kills WHERE accountId = :accountId"; private static final String DELETE_LOOT_ACCOUNT = "DELETE FROM kills WHERE accountId = :accountId";
private static final String DELETE_LOOT_ACCOUNT_EVENTID = "DELETE FROM kills WHERE accountId = :accountId AND eventId = :eventId"; private static final String DELETE_LOOT_ACCOUNT_EVENTID = "DELETE FROM kills WHERE accountId = :accountId AND eventId = :eventId";
@@ -119,7 +119,7 @@ public class LootTrackerService
} }
} }
public Collection<LootRecord> get(int accountId, int limit) public Collection<LootRecord> get(int accountId, int limit, int offset)
{ {
List<LootResult> lootResults; List<LootResult> lootResults;
@@ -128,6 +128,7 @@ public class LootTrackerService
lootResults = con.createQuery(SELECT_LOOT_QUERY) lootResults = con.createQuery(SELECT_LOOT_QUERY)
.addParameter("accountId", accountId) .addParameter("accountId", accountId)
.addParameter("limit", limit) .addParameter("limit", limit)
.addParameter("offset", offset)
.executeAndFetch(LootResult.class); .executeAndFetch(LootResult.class);
} }