Fixed math on player retention

This commit is contained in:
Rsl1122 2019-08-25 11:05:21 +03:00
parent 7f1212c1ac
commit ebbd2b50ff
3 changed files with 11 additions and 11 deletions

View File

@ -380,7 +380,7 @@ public class ActivityIndexQueries {
statement.setString(3, serverUUID.toString());
// Have played in the last half of the time frame
long half = before - (after - before) / 2;
long half = before + (before - after) / 2;
statement.setLong(4, half);
statement.setLong(5, before);
statement.setString(6, serverUUID.toString());
@ -421,7 +421,7 @@ public class ActivityIndexQueries {
statement.setString(3, serverUUID.toString());
// Have played in the last half of the time frame
long half = before - (after - before) / 2;
long half = before + (before - after) / 2;
statement.setLong(4, half);
statement.setLong(5, before);
statement.setString(6, serverUUID.toString());

View File

@ -363,7 +363,7 @@ public class NetworkActivityIndexQueries {
statement.setLong(2, after);
// Have played in the last half of the time frame
long half = before - (after - before) / 2;
long half = before + (before - after) / 2;
statement.setLong(3, half);
statement.setLong(4, before);
setSelectActivityIndexSQLParameters(statement, 5, threshold, before);
@ -400,7 +400,7 @@ public class NetworkActivityIndexQueries {
statement.setLong(2, after);
// Have played in the last half of the time frame
long half = before - (after - before) / 2;
long half = before + (before - after) / 2;
statement.setLong(3, half);
statement.setLong(4, before);
setSelectActivityIndexSQLParameters(statement, 5, threshold, before);

View File

@ -342,11 +342,11 @@ public class PlayerCountQueries {
public static Query<Integer> retainedPlayerCount(long after, long before, UUID serverUUID) {
String selectNewUUIDs = SELECT + UserInfoTable.USER_UUID +
FROM + UserInfoTable.TABLE_NAME +
WHERE + UserInfoTable.REGISTERED + "<=?" +
AND + UserInfoTable.REGISTERED + ">=?" +
WHERE + UserInfoTable.REGISTERED + ">=?" +
AND + UserInfoTable.REGISTERED + "<=?" +
AND + UserInfoTable.SERVER_UUID + "=?";
String selectUniqueUUIDs = SELECT + "DISTINCT " + SessionsTable.USER_UUID +
String selectUniqueUUIDs = SELECT + DISTINCT + SessionsTable.USER_UUID +
FROM + SessionsTable.TABLE_NAME +
WHERE + SessionsTable.SESSION_START + ">=?" +
AND + SessionsTable.SESSION_END + "<=?" +
@ -354,17 +354,17 @@ public class PlayerCountQueries {
String sql = SELECT + "COUNT(1) as player_count" +
FROM + '(' + selectNewUUIDs + ") q1" +
INNER_JOIN + '(' + selectUniqueUUIDs + ") q2 on q1." + SessionsTable.USER_UUID + "=q2." + SessionsTable.USER_UUID;
INNER_JOIN + '(' + selectUniqueUUIDs + ") q2 on q1." + UserInfoTable.USER_UUID + "=q2." + SessionsTable.USER_UUID;
return new QueryStatement<Integer>(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setLong(1, before);
statement.setLong(2, after);
statement.setLong(1, after);
statement.setLong(2, before);
statement.setString(3, serverUUID.toString());
// Have played in the last half of the time frame
long half = before - (after - before) / 2;
long half = before + (before - after) / 2;
statement.setLong(4, half);
statement.setLong(5, before);
statement.setString(6, serverUUID.toString());