diff --git a/gemp-lotr/db/play-stats.sql b/gemp-lotr/db/play-stats.sql new file mode 100644 index 000000000..11faa7e48 --- /dev/null +++ b/gemp-lotr/db/play-stats.sql @@ -0,0 +1,35 @@ +SELECT + G.DateOnly AS Date + ,G.game_count + ,P2.player_count +FROM +( + SELECT + COUNT(*) AS game_count + ,DATE(start_date) AS DateOnly + FROM game_history gh + GROUP BY DateOnly +) G + +INNER JOIN +( + SELECT + COUNT(*) AS player_count + ,P.DateOnly + FROM ( + SELECT + winner AS player + ,DATE(start_date) AS DateOnly + FROM game_history gh + + UNION + + SELECT + loser AS player + ,DATE(start_date) AS DateOnly + FROM game_history gh + ) P + GROUP BY DateOnly +) P2 +ON P2.DateOnly = G.DateOnly +ORDER BY G.DateOnly diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/GetStatsConsole.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/GetStatsConsole.java deleted file mode 100644 index 369be165c..000000000 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/GetStatsConsole.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.gempukku.lotro.game; - -import com.gempukku.lotro.db.DbAccess; -import com.gempukku.lotro.db.DbGameHistoryDAO; -import com.gempukku.lotro.db.GameHistoryDAO; - -import java.text.DecimalFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - -public class GetStatsConsole { - private static final SimpleDateFormat monthFormat = new SimpleDateFormat("MMM yyyy"); - private static final SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - private static final SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd"); - private static final DecimalFormat percFormat = new DecimalFormat("#0.0%"); - - public static void main(String[] args) throws ParseException { - DbAccess dbAccess = new DbAccess(); - GameHistoryDAO gameHistoryDAO = new DbGameHistoryDAO(dbAccess); - GameHistoryService gameHistoryService = new GameHistoryService(gameHistoryDAO); - - createGameActiveGamesStats(gameHistoryService); - } - - private static void createGameActiveGamesStats(GameHistoryService gameHistoryService) throws ParseException { - timeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - Date date = timeFormat.parse("2012-01-01 00:00:00"); - Date nextDay = timeFormat.parse("2012-01-02 00:00:00"); - Date nextWeek = timeFormat.parse("2012-01-08 00:00:00"); - - while (nextDay.getTime() < System.currentTimeMillis()) { - int gamesCount = gameHistoryService.getGamesPlayedCount(date.getTime(), nextDay.getTime() - date.getTime()); - int playersCount = gameHistoryService.getActivePlayersCount(date.getTime(), nextWeek.getTime() - date.getTime()); - - System.out.println(dayFormat.format(date) + "," + gamesCount + "," + playersCount); - - date.setDate(date.getDate() + 1); - nextDay.setDate(nextDay.getDate() + 1); - nextWeek.setDate(nextWeek.getDate() + 1); - } - } -}