Public Access
fix(sync): keep old playtime off the day a game shows up
A game the sync saw for the first time put its whole playtime on that day (40 h "longest gaming day" after skip_unvetted_apps=0). Growth now counts at most Steam's last two weeks, and one game gets at most 24 h per day. V18 drops the bad rows and caps old ones.
This commit is contained in:
1 parent
0fa2a37f47
commit
01552ecd89
6 files changed
+88
-9
No files matched your search
@@ -35,6 +35,16 @@ class PlaytimeDayRepositoryTest extends AbstractPersistenceTest {
|
||||
assertEquals(List.of(new DayMinutes(DAY, 75)), playtimeDayRepository.minutesPerDay(USER_ID, DAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMinutes_OneGameGetsAtMostOneDay() {
|
||||
playtimeDayRepository.addMinutes(USER_ID, 220L, DAY, 2378);
|
||||
playtimeDayRepository.addMinutes(USER_ID, 620L, DAY.plusDays(1), 1400);
|
||||
playtimeDayRepository.addMinutes(USER_ID, 620L, DAY.plusDays(1), 180);
|
||||
|
||||
assertEquals(List.of(new DayMinutes(DAY, 1440), new DayMinutes(DAY.plusDays(1), 1440)),
|
||||
playtimeDayRepository.minutesPerDay(USER_ID, DAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void minutesPerDay_SumsAllGamesOfTheUserFromTheGivenDay() {
|
||||
playtimeDayRepository.addMinutes(USER_ID, 220L, DAY.minusDays(1), 999);
|
||||
|
||||
@@ -290,6 +290,46 @@ class LibrarySyncWorkerTest extends AbstractUnitTest {
|
||||
verify(playtimeDayRepository).addMinutes(USER_ID, 220L, today(), 45);
|
||||
}
|
||||
|
||||
@Test
|
||||
void runSync_NewGameWithOldPlaytime_RecordsOnlyTheLastTwoWeeks() {
|
||||
steamReturns(game(2378, 30), STEAM_ID);
|
||||
|
||||
worker.runSync(USER_ID, STEAM_ID);
|
||||
|
||||
verify(playtimeDayRepository).addMinutes(USER_ID, 220L, today(), 30);
|
||||
}
|
||||
|
||||
@Test
|
||||
void runSync_NewGameNotPlayedForTwoWeeks_RecordsNothingAndLeavesThePileAlone() {
|
||||
steamReturns(game(2378, 0), STEAM_ID);
|
||||
|
||||
worker.runSync(USER_ID, STEAM_ID);
|
||||
|
||||
verify(playtimeDayRepository, never()).addMinutes(anyLong(), anyLong(), any(), anyInt());
|
||||
verify(userGameRepository, never()).playFromPileIfUntouched(anyLong(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void runSync_GrowthOverManyDays_RecordsAtMostTheLastTwoWeeks() {
|
||||
owned(100);
|
||||
steamReturns(game(1000, 60), STEAM_ID);
|
||||
|
||||
worker.runSync(USER_ID, STEAM_ID);
|
||||
|
||||
verify(playtimeDayRepository).addMinutes(USER_ID, 220L, today(), 60);
|
||||
}
|
||||
|
||||
@Test
|
||||
void runSync_GrowthOlderThanTwoWeeks_RecordsNothingButTakesTheGameFromThePile() {
|
||||
owned(100);
|
||||
steamReturns(game(160, 0), STEAM_ID);
|
||||
|
||||
worker.runSync(USER_ID, STEAM_ID);
|
||||
|
||||
verify(playtimeDayRepository, never()).addMinutes(anyLong(), anyLong(), any(), anyInt());
|
||||
verify(userGameRepository).playFromPileIfUntouched(USER_ID, List.of(220L));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runSync_FirstSync_IsOnlyTheBaseline() {
|
||||
steamReturns(game(5000, 60), null);
|
||||
|
||||
Reference in new issue
Block a user