Rename database column SOURCE to ADDON_ID.

Also rename VERSION to ADDON_VERSION and backport query-scripts changes.
This commit is contained in:
Pentarctagon 2023-01-06 23:48:24 -06:00
parent 2c3e674e89
commit e039ee8c18
32 changed files with 82 additions and 29 deletions

View file

@ -325,12 +325,12 @@ void dbconn::insert_game_player_info(const std::string& uuid, int game_id, const
log_sql_exception("Failed to insert game player info row for UUID `"+uuid+"` and game ID `"+std::to_string(game_id)+"`", e);
}
}
unsigned long long dbconn::insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version)
unsigned long long dbconn::insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& addon_id, const std::string& addon_version)
{
try
{
return modify(connection_, "INSERT INTO `"+db_game_content_info_table_+"`(INSTANCE_UUID, GAME_ID, TYPE, NAME, ID, SOURCE, VERSION) VALUES(?, ?, ?, ?, ?, ?, ?)",
uuid, game_id, type, name, id, source, version);
return modify(connection_, "INSERT INTO `"+db_game_content_info_table_+"`(INSTANCE_UUID, GAME_ID, TYPE, NAME, ID, ADDON_ID, ADDON_VERSION) VALUES(?, ?, ?, ?, ?, ?, ?)",
uuid, game_id, type, name, id, addon_id, addon_version);
}
catch(const mariadb::exception::base& e)
{

View file

@ -137,7 +137,7 @@ class dbconn
/**
* @see forum_user_handler::db_insert_game_content_info().
*/
unsigned long long insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version);
unsigned long long insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& addon_id, const std::string& addon_version);
/**
* @see forum_user_handler::db_set_oos_flag().

View file

@ -219,8 +219,8 @@ void fuh::db_insert_game_player_info(const std::string& uuid, int game_id, const
conn_.insert_game_player_info(uuid, game_id, username, side_number, is_host, faction, version, source, current_user);
}
unsigned long long fuh::db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version){
return conn_.insert_game_content_info(uuid, game_id, type, name, id, source, version);
unsigned long long fuh::db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& addon_id, const std::string& addon_version){
return conn_.insert_game_content_info(uuid, game_id, type, name, id, addon_id, addon_version);
}
void fuh::db_set_oos_flag(const std::string& uuid, int game_id){

View file

@ -178,11 +178,11 @@ public:
* @param type The add-on content's type (ie: era, scenario, etc).
* @param name The name of the content.
* @param id The id of the content.
* @param source The source add-on for the content.
* @param addon_id The source add-on for the content.
* @param version The version of the source add-on.
* @return The number of rows inserted which should always be 1.
*/
unsigned long long db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version);
unsigned long long db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& addon_id, const std::string& addon_version);
/**
* Sets the OOS flag in the database if wesnothd is told by a client it has detected an OOS error.

View file

@ -140,7 +140,7 @@ public:
virtual void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, int reload, int observers, int is_public, int has_password) = 0;
virtual void db_update_game_end(const std::string& uuid, int game_id, const std::string& replay_location) = 0;
virtual void db_insert_game_player_info(const std::string& uuid, int game_id, const std::string& username, int side_number, int is_host, const std::string& faction, const std::string& version, const std::string& source, const std::string& current_user) = 0;
virtual unsigned long long db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version) = 0;
virtual unsigned long long db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& addon_id, const std::string& addon_version) = 0;
virtual void db_set_oos_flag(const std::string& uuid, int game_id) = 0;
virtual void async_test_query(boost::asio::io_service& io_service, int limit) = 0;
virtual bool db_topic_id_exists(int topic_id) = 0;

View file

@ -0,0 +1,11 @@
select date(game.START_TIME) as GAME_DATE, count(distinct player.USER_ID) as PLAYER_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
group by GAME_DATE
order by GAME_DATE

View file

@ -0,0 +1,12 @@
select date(START_TIME) as GAME_DATE, count(distinct player.USER_ID) as PLAYER_COUNT, 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 game.INSTANCE_UUID = player.INSTANCE_UUID
and game.GAME_ID = player.GAME_ID
and player.USER_ID != -1
and player.CLIENT_SOURCE != ''
group by GAME_DATE, player.CLIENT_SOURCE
order by GAME_DATE, player.CLIENT_SOURCE

View file

@ -0,0 +1,12 @@
select count(*) as NEW_USERS_FIRST_GAME
from
(
select player.USER_ID, min(game.START_TIME) as FIRST_GAME_START
from wesnothd_game_info game, wesnothd_game_player_info player
where game.INSTANCE_UUID = player.INSTANCE_UUID
and game.GAME_ID = player.GAME_ID
group by player.USER_ID
) as temp
where YEAR(FIRST_GAME_START) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and MONTH(FIRST_GAME_START) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)

View file

@ -0,0 +1,13 @@
select count(*) as NEW_USERS_FIRST_GAME, CLIENT_SOURCE
from
(
select player.USER_ID, min(game.START_TIME) as FIRST_GAME_START, CLIENT_SOURCE
from wesnothd_game_info game, wesnothd_game_player_info player
where game.INSTANCE_UUID = player.INSTANCE_UUID
and game.GAME_ID = player.GAME_ID
and player.CLIENT_SOURCE != ''
group by player.USER_ID, CLIENT_SOURCE
) as temp
where YEAR(FIRST_GAME_START) = YEAR(CURRENT_DATE - INTERVAL 2 MONTH)
and MONTH(FIRST_GAME_START) = MONTH(CURRENT_DATE - INTERVAL 2 MONTH)
group by CLIENT_SOURCE

View file

@ -1,4 +1,4 @@
select CLIENT_SOURCE, count(*) as GAME_COUNT
select CLIENT_SOURCE, count(*) as CLIENT_COUNT
from
(
select distinct player.USER_ID, player.CLIENT_SOURCE
@ -10,6 +10,7 @@ from
and player.USER_ID != -1
and game.INSTANCE_UUID = player.INSTANCE_UUID
and game.GAME_ID = player.GAME_ID
and player.CLIENT_SOURCE != ''
) src
group by CLIENT_SOURCE
order by COUNT(*) desc

View file

@ -10,6 +10,7 @@ from
and game.INSTANCE_UUID = player.INSTANCE_UUID
and game.GAME_ID = player.GAME_ID
and player.USER_ID != -1
and player.CLIENT_VERSION != ''
) src
group by CLIENT_VERSION
order by COUNT(*) desc

View file

@ -1,4 +1,4 @@
select content.ID as ERA, content.SOURCE as ADDON, content.VERSION, count(*) as ERA_COUNT
select content.ID as ERA, content.ADDON_ID as ADDON, content.ADDON_VERSION, count(*) as ERA_COUNT
from wesnothd_game_info game, wesnothd_game_content_info content
where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)
@ -7,5 +7,5 @@ where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and game.INSTANCE_UUID = content.INSTANCE_UUID
and game.GAME_ID = content.GAME_ID
and content.TYPE = 'era'
group by content.ID, content.SOURCE, content.VERSION
group by content.ID, content.ADDON_ID, content.ADDON_VERSION
order by count(*) desc

View file

@ -1,4 +1,4 @@
select content.ID as MAP, content.SOURCE as ADDON, content.VERSION, count(*) as MAP_COUNT
select content.ID as MAP, content.ADDON_ID as ADDON, content.ADDON_VERSION, count(*) as MAP_COUNT
from wesnothd_game_info game, wesnothd_game_content_info content
where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)
@ -7,5 +7,5 @@ where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and game.INSTANCE_UUID = content.INSTANCE_UUID
and game.GAME_ID = content.GAME_ID
and content.TYPE = 'scenario'
group by content.ID, content.SOURCE, content.VERSION
group by content.ID, content.ADDON_ID, content.ADDON_VERSION
order by count(*) desc

View file

@ -1,4 +1,4 @@
select IFNULL(content.ID,'No Modifications') as MODIFICATION, IFNULL(content.SOURCE,'') as ADDON, IFNULL(content.VERSION,'') as VERSION, count(*) as MODIFICATION_COUNT
select IFNULL(content.ID,'No Modifications') as MODIFICATION, IFNULL(content.ADDON_ID,'') as ADDON, IFNULL(content.ADDON_VERSION,'') as VERSION, count(*) as MODIFICATION_COUNT
from wesnothd_game_info game
left join wesnothd_game_content_info content
on game.INSTANCE_UUID = content.INSTANCE_UUID
@ -8,5 +8,5 @@ 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 content.ID, content.SOURCE, content.VERSION
group by content.ID, content.ADDON_ID, content.ADDON_VERSION
order by count(*) desc

View file

@ -1,4 +1,4 @@
select content.ID as ERA, content.SOURCE as ADDON, content.VERSION, count(*) as OOS_COUNT
select content.ID as ERA, content.ADDON_ID as ADDON, content.ADDON_VERSION, count(*) as OOS_COUNT
from wesnothd_game_info game, wesnothd_game_content_info content
where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)
@ -8,5 +8,5 @@ where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and game.INSTANCE_UUID = content.INSTANCE_UUID
and game.GAME_ID = content.GAME_ID
and content.TYPE = 'era'
group by content.ID, content.SOURCE, content.VERSION
group by content.ID, content.ADDON_ID, content.ADDON_VERSION
order by count(*) desc

View file

@ -1,4 +1,4 @@
select content.ID as MAP, content.SOURCE as ADDON, content.VERSION, count(*) as OOS_COUNT
select content.ID as MAP, content.ADDON_ID as ADDON, content.ADDON_VERSION, count(*) as OOS_COUNT
from wesnothd_game_info game, wesnothd_game_content_info content
where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and MONTH(game.START_TIME) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)
@ -8,5 +8,5 @@ where YEAR(game.START_TIME) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
and game.INSTANCE_UUID = content.INSTANCE_UUID
and game.GAME_ID = content.GAME_ID
and content.TYPE = 'scenario'
group by content.ID, content.SOURCE, content.VERSION
group by content.ID, content.ADDON_ID, content.ADDON_VERSION
order by count(*) desc

View file

@ -1,4 +1,4 @@
select content.ID as MODIFICATION, content.SOURCE as ADDON, content.VERSION, count(*) as OOS_COUNT
select content.ID as MODIFICATION, content.ADDON_ID as ADDON, content.ADDON_VERSION, count(*) as OOS_COUNT
from wesnothd_game_info game, wesnothd_game_content_info content
where game.INSTANCE_UUID = content.INSTANCE_UUID
and game.GAME_ID = content.GAME_ID
@ -8,5 +8,5 @@ where game.INSTANCE_UUID = content.INSTANCE_UUID
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 content.ID, content.SOURCE, content.VERSION
group by content.ID, content.ADDON_ID, content.ADDON_VERSION
order by count(*) desc

View file

@ -1,4 +1,4 @@
select count(*) as OOS_COUNT, eras.ID as ERA, eras.SOURCE as ERA_ADDON, eras.VERSION as ERA_VERSION, scenarios.ID as MAP, scenarios.SOURCE as MAP_ADDON, scenarios.VERSION as MAP_VERSION, IFNULL(GROUP_CONCAT(distinct concat(mods.ID,'(',mods.SOURCE,':',mods.VERSION,')') SEPARATOR '|'), 'No Modifications') AS MODIFICATIONS
select count(*) as OOS_COUNT, eras.ID as ERA, eras.ADDON_ID as ERA_ADDON, eras.ADDON_VERSION as ERA_VERSION, scenarios.ID as MAP, scenarios.ADDON_ID as MAP_ADDON, scenarios.ADDON_VERSION as MAP_VERSION, IFNULL(GROUP_CONCAT(distinct concat(mods.ID,'(',mods.ADDON_ID,':',mods.ADDON_VERSION,')') SEPARATOR '|'), 'No Modifications') AS MODIFICATIONS
from wesnothd_game_info game
inner join wesnothd_game_content_info scenarios
on game.INSTANCE_UUID = scenarios.INSTANCE_UUID
@ -17,5 +17,5 @@ where game.OOS = 1
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 eras.ID, eras.SOURCE, eras.VERSION, scenarios.ID, scenarios.SOURCE, scenarios.VERSION
group by eras.ID, eras.ADDON_ID, eras.ADDON_VERSION, scenarios.ID, scenarios.ADDON_ID, scenarios.ADDON_VERSION
order by count(*) desc, eras.ID, scenarios.ID, mods.ID

View file

@ -1,4 +1,4 @@
select eras.ID as ERA, eras.SOURCE as ERA_ADDON, eras.VERSION as ERA_VERSION, scenarios.ID as MAP, scenarios.SOURCE as MAP_ADDON, scenarios.VERSION as MAP_VERSION, IFNULL(GROUP_CONCAT(distinct concat(mods.ID,'(',mods.SOURCE,':',mods.VERSION,')') SEPARATOR '|'), 'No Modifications') AS MODIFICATIONS, concat('https://replays.wesnoth.org/', substring(game.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
select eras.ID as ERA, eras.ADDON_ID as ERA_ADDON, eras.ADDON_VERSION as ERA_VERSION, scenarios.ID as MAP, scenarios.ADDON_ID as MAP_ADDON, scenarios.ADDON_VERSION as MAP_VERSION, IFNULL(GROUP_CONCAT(distinct concat(mods.ID,'(',mods.ADDON_ID,':',mods.ADDON_VERSION,')') SEPARATOR '|'), 'No Modifications') AS MODIFICATIONS, concat('https://replays.wesnoth.org/', substring(game.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
inner join wesnothd_game_content_info scenarios
on game.INSTANCE_UUID = scenarios.INSTANCE_UUID

View file

@ -0,0 +1,3 @@
select INSTANCE_VERSION, ADDON_ID, VERSION, UPLOADED_ON, DOWNLOAD_COUNT
from campaignd_addon_info
order by INSTANCE_VERSION, ADDON_ID, VERSION

View file

@ -111,8 +111,8 @@ CREATE INDEX USER_ID_IDX ON game_player_info(USER_ID);
-- TYPE: one of era/scenario/modification/campaign
-- ID: the id of the content
-- NAME: the content's user-visible name
-- SOURCE: the id of the add-on that the particular content came from
-- VERSION: the version of the source add-on
-- ADDON_ID: the id of the add-on that the particular content came from
-- ADDON_VERSION: the version of the source add-on
create table game_content_info
(
INSTANCE_UUID CHAR(36) NOT NULL,
@ -120,8 +120,8 @@ create table game_content_info
TYPE VARCHAR(100) NOT NULL,
ID VARCHAR(100) NOT NULL,
NAME VARCHAR(255),
SOURCE VARCHAR(100) NOT NULL,
VERSION VARCHAR(255) NOT NULL,
ADDON_ID VARCHAR(100) NOT NULL,
ADDON_VERSION VARCHAR(255) NOT NULL,
PRIMARY KEY (INSTANCE_UUID, GAME_ID, TYPE, ID, SOURCE)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;