mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-22 09:08:01 +01:00
Stop JSON cache mismatch when UUID is missing
The check for {identifier}- meant that lookup for "PLAYERS_ONLINE-" would also match "PLAYERS_ONLINE-{uuid}-" since start is the same Fixed this by changing identifiers to PLAYERS_ONLINE_{uuid}-{timestamp} Affects issues: - Fixed #3404
This commit is contained in:
parent
1fdd3289a6
commit
ae85f39871
@ -61,6 +61,6 @@ public enum DataID {
|
||||
|
||||
public String of(ServerUUID serverUUID) {
|
||||
if (serverUUID == null) return name();
|
||||
return name() + '-' + serverUUID;
|
||||
return name() + "_" + serverUUID;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.webserver.cache;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -145,7 +146,7 @@ class JSONStorageTest {
|
||||
@Test
|
||||
void storedWithLaterDateIsNotFetched() {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
JSONStorage.StoredJSON stored = UNDER_TEST.storeJson("Identifier", Collections.singletonList("data"), timestamp);
|
||||
UNDER_TEST.storeJson("Identifier", Collections.singletonList("data"), timestamp);
|
||||
assertFalse(UNDER_TEST.fetchJsonMadeAfter("Identifier", timestamp + TimeUnit.DAYS.toMillis(1L)).isPresent());
|
||||
}
|
||||
|
||||
@ -160,14 +161,21 @@ class JSONStorageTest {
|
||||
@Test
|
||||
void storedWithEarlierDateIsNotFetched() {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
JSONStorage.StoredJSON stored = UNDER_TEST.storeJson("Identifier", Collections.singletonList("data"), timestamp);
|
||||
UNDER_TEST.storeJson("Identifier", Collections.singletonList("data"), timestamp);
|
||||
assertFalse(UNDER_TEST.fetchJsonMadeBefore("Identifier", timestamp - TimeUnit.DAYS.toMillis(1L)).isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotFetchWrongThing() {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
JSONStorage.StoredJSON stored = UNDER_TEST.storeJson(DataID.SESSIONS_OVERVIEW.name(), Collections.singletonList("data"), timestamp);
|
||||
UNDER_TEST.storeJson(DataID.SESSIONS_OVERVIEW.name(), Collections.singletonList("data"), timestamp);
|
||||
assertFalse(UNDER_TEST.fetchJsonMadeBefore(DataID.SESSIONS.name(), timestamp + TimeUnit.DAYS.toMillis(1L)).isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotFetchWrongServer() {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
UNDER_TEST.storeJson(DataID.SESSIONS_OVERVIEW.of(ServerUUID.randomUUID()), Collections.singletonList("data"), timestamp);
|
||||
assertFalse(UNDER_TEST.fetchJsonMadeBefore(DataID.SESSIONS_OVERVIEW.name(), timestamp + TimeUnit.DAYS.toMillis(1L)).isPresent());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user