Fixed SessionsMutator filtering sessions improperly

This commit is contained in:
Rsl1122 2018-06-05 14:22:56 +03:00
parent 657b25ec4f
commit 7415c3ebe2
2 changed files with 7 additions and 5 deletions

View File

@ -33,7 +33,7 @@ public class SessionsMutator {
public SessionsMutator filterSessionsBetween(long after, long before) {
sessions = sessions.stream()
.filter(session -> session.getSessionEnd() < after && session.getSessionStart() > before)
.filter(session -> session.getSessionEnd() >= after && session.getSessionStart() <= before)
.collect(Collectors.toList());
return this;
}

View File

@ -1,6 +1,5 @@
package com.djrapitops.plan.data.calculation;
import com.djrapitops.plan.data.PlayerProfile;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
@ -76,6 +75,8 @@ public class ActivityIndexTest {
sessions.add(new Session(0, threeWeeksAgo, threeWeeksAgo + requiredPlaytime * 3L, 0, 0, 0));
}
container.putRawData(PlayerKeys.SESSIONS, sessions);
assertTrue(container.supports(PlayerKeys.SESSIONS));
assertTrue(container.getValue(PlayerKeys.SESSIONS).isPresent());
assertEquals(5.0, new ActivityIndex(container, date).getValue());
}
@ -106,14 +107,15 @@ public class ActivityIndexTest {
@Test(timeout = 500)
public void testTimeout() {
PlayerProfile p = new PlayerProfile(null, null, 0L);
PlayerContainer container = new PlayerContainer();
List<Session> sessions = new ArrayList<>();
long date = 0;
for (int i = 0; i < 5000; i++) {
sessions.add(new Session(0, 0, 0, 0, 0, 0));
}
p.setSessions(null, sessions);
p.getActivityIndex(0);
container.putRawData(PlayerKeys.SESSIONS, sessions);
new ActivityIndex(container, 0).getValue();
}
}