Add player count placeholders

- server_players_registered_{total/day/week/month}
- network_players_registered_{total/day/week/month}
- server_players_unique_{total/day/week/month}
- network_players_unique_{total/day/week/month}

Affects issues:
- Close #2189
This commit is contained in:
Risto Lahtela 2021-12-15 12:45:43 +02:00
parent 13fc7adbdd
commit 7a9791da2b

View File

@ -25,6 +25,7 @@ import com.djrapitops.plan.identification.ServerUUID;
import com.djrapitops.plan.storage.database.DBSystem;
import com.djrapitops.plan.storage.database.Database;
import com.djrapitops.plan.storage.database.queries.Query;
import com.djrapitops.plan.storage.database.queries.analysis.PlayerCountQueries;
import com.djrapitops.plan.storage.database.queries.analysis.TopListQueries;
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
import com.djrapitops.plan.storage.database.queries.objects.TPSQueries;
@ -71,6 +72,54 @@ public class ServerPlaceHolders implements Placeholders {
Database database = dbSystem.getDatabase();
placeholders.registerStatic("server_players_registered_total",
parameters -> database.query(PlayerCountQueries.newPlayerCount(0, now(), getServerUUID(parameters))));
placeholders.registerStatic("server_players_registered_day",
parameters -> database.query(PlayerCountQueries.newPlayerCount(dayAgo(), now(), getServerUUID(parameters))));
placeholders.registerStatic("server_players_registered_week",
parameters -> database.query(PlayerCountQueries.newPlayerCount(weekAgo(), now(), getServerUUID(parameters))));
placeholders.registerStatic("server_players_registered_month",
parameters -> database.query(PlayerCountQueries.newPlayerCount(monthAgo(), now(), getServerUUID(parameters))));
placeholders.registerStatic("network_players_registered_total",
parameters -> database.query(PlayerCountQueries.newPlayerCount(0, now())));
placeholders.registerStatic("network_players_registered_day",
parameters -> database.query(PlayerCountQueries.newPlayerCount(dayAgo(), now())));
placeholders.registerStatic("network_players_registered_week",
parameters -> database.query(PlayerCountQueries.newPlayerCount(weekAgo(), now())));
placeholders.registerStatic("network_players_registered_month",
parameters -> database.query(PlayerCountQueries.newPlayerCount(monthAgo(), now())));
placeholders.registerStatic("server_players_unique_total",
parameters -> database.query(PlayerCountQueries.newPlayerCount(0, now(), getServerUUID(parameters))));
placeholders.registerStatic("server_players_unique_day",
parameters -> database.query(PlayerCountQueries.uniquePlayerCount(dayAgo(), now(), getServerUUID(parameters))));
placeholders.registerStatic("server_players_unique_week",
parameters -> database.query(PlayerCountQueries.uniquePlayerCount(weekAgo(), now(), getServerUUID(parameters))));
placeholders.registerStatic("server_players_unique_month",
parameters -> database.query(PlayerCountQueries.uniquePlayerCount(monthAgo(), now(), getServerUUID(parameters))));
placeholders.registerStatic("network_players_unique_total",
parameters -> database.query(PlayerCountQueries.uniquePlayerCount(0, now())));
placeholders.registerStatic("network_players_unique_day",
parameters -> database.query(PlayerCountQueries.uniquePlayerCount(dayAgo(), now())));
placeholders.registerStatic("network_players_unique_week",
parameters -> database.query(PlayerCountQueries.uniquePlayerCount(weekAgo(), now())));
placeholders.registerStatic("network_players_unique_month",
parameters -> database.query(PlayerCountQueries.uniquePlayerCount(monthAgo(), now())));
placeholders.registerStatic("server_tps_day",
parameters -> decimals.apply(database.query(TPSQueries.averageTPS(dayAgo(), now(), getServerUUID(parameters)))));