From 67c169ed8032cccd3e8b58990327b94c0ca693ad Mon Sep 17 00:00:00 2001 From: Pentarctagon Date: Tue, 24 Mar 2020 12:32:13 -0500 Subject: [PATCH] Add scripts to pull various pieces of information from the MP database. The intent being that I plan to run these once a month and post the results on the forum. --- .../query-scripts/01-count-of-unique-users.sql | 9 +++++++++ .../query-scripts/02-count-of-games-of-month.sql | 6 ++++++ .../query-scripts/03-count-of-games-per-day.sql | 8 ++++++++ .../04-count-of-download-by-source.sql | 15 +++++++++++++++ .../query-scripts/05-count-of-versions.sql | 15 +++++++++++++++ .../query-scripts/06-eras-by-game-count.sql | 8 ++++++++ .../query-scripts/07-maps-by-game-count.sql | 8 ++++++++ .../08-modifications-by-game-count.sql | 11 +++++++++++ .../query-scripts/09-oos-vs-game-count.sql | 6 ++++++ .../query-scripts/10-oos-count-by-era.sql | 9 +++++++++ .../query-scripts/11-oos-count-by-map.sql | 9 +++++++++ .../12-oos-count-by-modification.sql | 11 +++++++++++ .../13-oos-count-by-era-map-modification.sql | 12 ++++++++++++ .../query-scripts/14-oos-replays-list.sql | 12 ++++++++++++ utils/mp-server/query-scripts/run-queries.sh | 6 ++++++ 15 files changed, 145 insertions(+) create mode 100644 utils/mp-server/query-scripts/01-count-of-unique-users.sql create mode 100644 utils/mp-server/query-scripts/02-count-of-games-of-month.sql create mode 100644 utils/mp-server/query-scripts/03-count-of-games-per-day.sql create mode 100644 utils/mp-server/query-scripts/04-count-of-download-by-source.sql create mode 100644 utils/mp-server/query-scripts/05-count-of-versions.sql create mode 100644 utils/mp-server/query-scripts/06-eras-by-game-count.sql create mode 100644 utils/mp-server/query-scripts/07-maps-by-game-count.sql create mode 100644 utils/mp-server/query-scripts/08-modifications-by-game-count.sql create mode 100644 utils/mp-server/query-scripts/09-oos-vs-game-count.sql create mode 100644 utils/mp-server/query-scripts/10-oos-count-by-era.sql create mode 100644 utils/mp-server/query-scripts/11-oos-count-by-map.sql create mode 100644 utils/mp-server/query-scripts/12-oos-count-by-modification.sql create mode 100644 utils/mp-server/query-scripts/13-oos-count-by-era-map-modification.sql create mode 100644 utils/mp-server/query-scripts/14-oos-replays-list.sql create mode 100755 utils/mp-server/query-scripts/run-queries.sh diff --git a/utils/mp-server/query-scripts/01-count-of-unique-users.sql b/utils/mp-server/query-scripts/01-count-of-unique-users.sql new file mode 100644 index 00000000000..be8451e3597 --- /dev/null +++ b/utils/mp-server/query-scripts/01-count-of-unique-users.sql @@ -0,0 +1,9 @@ +select count(distinct player.USER_ID) as USER_COUNT +from wesnothd_game_info game, wesnothd_game_player_info player +where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and game.END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, game.START_TIME, game.END_TIME) > 5 + and game.INSTANCE_UUID = player.INSTANCE_UUID + and game.GAME_ID = player.GAME_ID + and player.USER_ID != -1 diff --git a/utils/mp-server/query-scripts/02-count-of-games-of-month.sql b/utils/mp-server/query-scripts/02-count-of-games-of-month.sql new file mode 100644 index 00000000000..115f2dedecf --- /dev/null +++ b/utils/mp-server/query-scripts/02-count-of-games-of-month.sql @@ -0,0 +1,6 @@ +select count(*) as GAME_COUNT +from wesnothd_game_info +where YEAR(START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, START_TIME, END_TIME) > 5 diff --git a/utils/mp-server/query-scripts/03-count-of-games-per-day.sql b/utils/mp-server/query-scripts/03-count-of-games-per-day.sql new file mode 100644 index 00000000000..488077ad222 --- /dev/null +++ b/utils/mp-server/query-scripts/03-count-of-games-per-day.sql @@ -0,0 +1,8 @@ +select date(START_TIME) as GAME_DATE, count(*) as GAME_COUNT +from wesnothd_game_info +where YEAR(START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, START_TIME, END_TIME) > 5 +group by GAME_DATE +order by GAME_DATE diff --git a/utils/mp-server/query-scripts/04-count-of-download-by-source.sql b/utils/mp-server/query-scripts/04-count-of-download-by-source.sql new file mode 100644 index 00000000000..dca29e56ee6 --- /dev/null +++ b/utils/mp-server/query-scripts/04-count-of-download-by-source.sql @@ -0,0 +1,15 @@ +select CLIENT_SOURCE, count(*) as GAME_COUNT +from +( + select distinct player.USER_ID, player.CLIENT_SOURCE + from wesnothd_game_info game, wesnothd_game_player_info player + where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and game.END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, game.START_TIME, game.END_TIME) > 5 + and player.USER_ID != -1 + and game.INSTANCE_UUID = player.INSTANCE_UUID + and game.GAME_ID = player.GAME_ID +) src +group by CLIENT_SOURCE +order by COUNT(*) desc diff --git a/utils/mp-server/query-scripts/05-count-of-versions.sql b/utils/mp-server/query-scripts/05-count-of-versions.sql new file mode 100644 index 00000000000..b480d582324 --- /dev/null +++ b/utils/mp-server/query-scripts/05-count-of-versions.sql @@ -0,0 +1,15 @@ +select CLIENT_VERSION, count(*) as VERSION_COUNT +from +( + select distinct player.USER_ID, player.CLIENT_VERSION + from wesnothd_game_info game, wesnothd_game_player_info player + where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and game.END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, game.START_TIME, game.END_TIME) > 5 + and game.INSTANCE_UUID = player.INSTANCE_UUID + and game.GAME_ID = player.GAME_ID + and player.USER_ID != -1 +) src +group by CLIENT_VERSION +order by COUNT(*) desc diff --git a/utils/mp-server/query-scripts/06-eras-by-game-count.sql b/utils/mp-server/query-scripts/06-eras-by-game-count.sql new file mode 100644 index 00000000000..a2e656740df --- /dev/null +++ b/utils/mp-server/query-scripts/06-eras-by-game-count.sql @@ -0,0 +1,8 @@ +select ERA_NAME, count(*) as ERA_COUNT +from wesnothd_game_info +where YEAR(START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, START_TIME, END_TIME) > 5 +group by ERA_NAME +order by count(*) desc diff --git a/utils/mp-server/query-scripts/07-maps-by-game-count.sql b/utils/mp-server/query-scripts/07-maps-by-game-count.sql new file mode 100644 index 00000000000..adef9b08b01 --- /dev/null +++ b/utils/mp-server/query-scripts/07-maps-by-game-count.sql @@ -0,0 +1,8 @@ +select MAP_NAME, count(*) as MAP_COUNT +from wesnothd_game_info +where YEAR(START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, START_TIME, END_TIME) > 5 +group by MAP_NAME +order by count(*) desc diff --git a/utils/mp-server/query-scripts/08-modifications-by-game-count.sql b/utils/mp-server/query-scripts/08-modifications-by-game-count.sql new file mode 100644 index 00000000000..02db016d75d --- /dev/null +++ b/utils/mp-server/query-scripts/08-modifications-by-game-count.sql @@ -0,0 +1,11 @@ +select IFNULL(MODIFICATION_NAME,'No Modifications') as MODIFICATION_NAME, count(*) as MODIFICATION_COUNT +from wesnothd_game_info game +left join wesnothd_game_modification_info modif + on game.INSTANCE_UUID = modif.INSTANCE_UUID + and game.GAME_ID = modif.GAME_ID +where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and game.END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, game.START_TIME, game.END_TIME) > 5 +group by MODIFICATION_NAME +order by count(*) desc diff --git a/utils/mp-server/query-scripts/09-oos-vs-game-count.sql b/utils/mp-server/query-scripts/09-oos-vs-game-count.sql new file mode 100644 index 00000000000..da667a5ae09 --- /dev/null +++ b/utils/mp-server/query-scripts/09-oos-vs-game-count.sql @@ -0,0 +1,6 @@ +select count(*) as GAME_COUNT, sum(OOS) as OOS_COUNT +from wesnothd_game_info +where YEAR(START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, START_TIME, END_TIME) > 5 diff --git a/utils/mp-server/query-scripts/10-oos-count-by-era.sql b/utils/mp-server/query-scripts/10-oos-count-by-era.sql new file mode 100644 index 00000000000..ac91c3d8bbc --- /dev/null +++ b/utils/mp-server/query-scripts/10-oos-count-by-era.sql @@ -0,0 +1,9 @@ +select ERA_NAME, count(*) as OOS_COUNT +from wesnothd_game_info +where YEAR(START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, START_TIME, END_TIME) > 5 + and OOS = 1 +group by ERA_NAME +order by count(*) desc diff --git a/utils/mp-server/query-scripts/11-oos-count-by-map.sql b/utils/mp-server/query-scripts/11-oos-count-by-map.sql new file mode 100644 index 00000000000..c6cfdf129fd --- /dev/null +++ b/utils/mp-server/query-scripts/11-oos-count-by-map.sql @@ -0,0 +1,9 @@ +select MAP_NAME, count(*) as OOS_COUNT +from wesnothd_game_info +where YEAR(START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, START_TIME, END_TIME) > 5 + and OOS = 1 +group by MAP_NAME +order by count(*) desc diff --git a/utils/mp-server/query-scripts/12-oos-count-by-modification.sql b/utils/mp-server/query-scripts/12-oos-count-by-modification.sql new file mode 100644 index 00000000000..953965b3912 --- /dev/null +++ b/utils/mp-server/query-scripts/12-oos-count-by-modification.sql @@ -0,0 +1,11 @@ +select modif.MODIFICATION_NAME, count(*) as OOS_COUNT +from wesnothd_game_info game, wesnothd_game_modification_info modif +where game.INSTANCE_UUID = modif.INSTANCE_UUID + and game.GAME_ID = modif.GAME_ID + and game.OOS = 1 + and YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and game.END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, game.START_TIME, game.END_TIME) > 5 +group by modif.MODIFICATION_NAME +order by count(*) desc diff --git a/utils/mp-server/query-scripts/13-oos-count-by-era-map-modification.sql b/utils/mp-server/query-scripts/13-oos-count-by-era-map-modification.sql new file mode 100644 index 00000000000..3a70a68b45a --- /dev/null +++ b/utils/mp-server/query-scripts/13-oos-count-by-era-map-modification.sql @@ -0,0 +1,12 @@ +select game.ERA_NAME, game.MAP_NAME, IFNULL(GROUP_CONCAT(distinct modif.MODIFICATION_NAME SEPARATOR '|'), 'No Modifications') AS MODIFICATIONS, count(*) as OOS_COUNT +from wesnothd_game_info game +left join wesnothd_game_modification_info modif + on game.INSTANCE_UUID = modif.INSTANCE_UUID + and game.GAME_ID = modif.GAME_ID +where game.OOS = 1 + and YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and game.END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, game.START_TIME, game.END_TIME) > 5 +group by game.ERA_NAME, game.MAP_NAME +order by count(*) desc, game.ERA_NAME, game.MAP_NAME, modif.MODIFICATION_NAME diff --git a/utils/mp-server/query-scripts/14-oos-replays-list.sql b/utils/mp-server/query-scripts/14-oos-replays-list.sql new file mode 100644 index 00000000000..4328225144b --- /dev/null +++ b/utils/mp-server/query-scripts/14-oos-replays-list.sql @@ -0,0 +1,12 @@ +select game.ERA_NAME, game.MAP_NAME, IFNULL(GROUP_CONCAT(distinct modif.MODIFICATION_NAME SEPARATOR '|'), 'No Modifications') AS MODIFICATIONS, concat('https://replays.wesnoth.org/', substring(INSTANCE_VERSION, 1, 4), '/', year(game.END_TIME), '/', lpad(month(game.END_TIME), 2, '0'), '/', lpad(day(game.END_TIME), 2, '0'), '/', game.REPLAY_NAME) AS REPLAY_LOCATION +from wesnothd_game_info game +left join wesnothd_game_modification_info modif + on game.INSTANCE_UUID = modif.INSTANCE_UUID + and game.GAME_ID = modif.GAME_ID +where game.OOS = 1 + and YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) + and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) + and game.END_TIME is not NULL + and TIMESTAMPDIFF(MINUTE, game.START_TIME, game.END_TIME) > 5 +group by game.INSTANCE_UUID, game.GAME_ID +order by game.ERA_NAME, game.MAP_NAME, modif.MODIFICATION_NAME diff --git a/utils/mp-server/query-scripts/run-queries.sh b/utils/mp-server/query-scripts/run-queries.sh new file mode 100755 index 00000000000..59f1e918837 --- /dev/null +++ b/utils/mp-server/query-scripts/run-queries.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +for sql in ./*.sql +do + mysql < "$sql" > "${sql}.tsv" +done