diff options
author | Sadie Powell <sadie@witchery.services> | 2022-01-09 19:33:29 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2022-01-10 16:20:56 +0000 |
commit | 0e6f8488d3a1552f41ec7c0ab57899040d739ea2 (patch) | |
tree | 14ba7ee78a5535ff229864dec38bde6921a47a48 /modules/extra/stats/irc2sql/tables.cpp | |
parent | 56687c27cb5045e7600c58f58c6e70efea4c87d1 (diff) |
Avoid duplicate checks in irc2sql.
Diffstat (limited to 'modules/extra/stats/irc2sql/tables.cpp')
-rw-r--r-- | modules/extra/stats/irc2sql/tables.cpp | 91 |
1 files changed, 48 insertions, 43 deletions
diff --git a/modules/extra/stats/irc2sql/tables.cpp b/modules/extra/stats/irc2sql/tables.cpp index e29a6d132..45fa301dd 100644 --- a/modules/extra/stats/irc2sql/tables.cpp +++ b/modules/extra/stats/irc2sql/tables.cpp @@ -25,52 +25,57 @@ void IRC2SQL::CheckTables() this->GetTables(); - if (GeoIPDB.equals_ci("country") && !this->HasTable(prefix + "geoip_country")) - { - query = "CREATE TABLE `" + prefix + "geoip_country` (" - "`start` INT UNSIGNED NOT NULL," - "`end` INT UNSIGNED NOT NULL," - "`countrycode` varchar(2)," - "`countryname` varchar(50)," - "PRIMARY KEY `end` (`end`)," - "KEY `start` (`start`)" - ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - this->RunQuery(query); - } - if (GeoIPDB.equals_ci("city") && !this->HasTable(prefix + "geoip_city_blocks")) + if (GeoIPDB.equals_ci("country")) { - query = "CREATE TABLE `" + prefix + "geoip_city_blocks` (" - "`start` INT UNSIGNED NOT NULL," - "`end` INT UNSIGNED NOT NULL," - "`locId` INT UNSIGNED NOT NULL," - "PRIMARY KEY `end` (`end`)," - "KEY `start` (`start`)" - ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - this->RunQuery(query); - + if (!this->HasTable(prefix + "geoip_country")) + { + query = "CREATE TABLE `" + prefix + "geoip_country` (" + "`start` INT UNSIGNED NOT NULL," + "`end` INT UNSIGNED NOT NULL," + "`countrycode` varchar(2)," + "`countryname` varchar(50)," + "PRIMARY KEY `end` (`end`)," + "KEY `start` (`start`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; + this->RunQuery(query); + } } - if (GeoIPDB.equals_ci("city") && !this->HasTable(prefix + "geoip_city_location")) + else if (GeoIPDB.equals_ci("city")) { - query = "CREATE TABLE `" + prefix + "geoip_city_location` (" - "`locId` INT UNSIGNED NOT NULL," - "`country` CHAR(2) NOT NULL," - "`region` CHAR(2) NOT NULL," - "`city` VARCHAR(50)," - "`latitude` FLOAT," - "`longitude` FLOAT," - "`areaCode` INT," - "PRIMARY KEY (`locId`)" - ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - this->RunQuery(query); - } - if (GeoIPDB.equals_ci("city") && !this->HasTable(prefix + "geoip_city_region")) - { query = "CREATE TABLE `" + prefix + "geoip_city_region` (" - "`country` CHAR(2) NOT NULL," - "`region` CHAR(2) NOT NULL," - "`regionname` VARCHAR(100) NOT NULL," - "PRIMARY KEY (`country`,`region`)" - ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - this->RunQuery(query); + if (!this->HasTable(prefix + "geoip_city_blocks")) + { + query = "CREATE TABLE `" + prefix + "geoip_city_blocks` (" + "`start` INT UNSIGNED NOT NULL," + "`end` INT UNSIGNED NOT NULL," + "`locId` INT UNSIGNED NOT NULL," + "PRIMARY KEY `end` (`end`)," + "KEY `start` (`start`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; + this->RunQuery(query); + } + if (!this->HasTable(prefix + "geoip_city_location")) + { + query = "CREATE TABLE `" + prefix + "geoip_city_location` (" + "`locId` INT UNSIGNED NOT NULL," + "`country` CHAR(2) NOT NULL," + "`region` CHAR(2) NOT NULL," + "`city` VARCHAR(50)," + "`latitude` FLOAT," + "`longitude` FLOAT," + "`areaCode` INT," + "PRIMARY KEY (`locId`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; + this->RunQuery(query); + } + if (!this->HasTable(prefix + "geoip_city_region")) + { query = "CREATE TABLE `" + prefix + "geoip_city_region` (" + "`country` CHAR(2) NOT NULL," + "`region` CHAR(2) NOT NULL," + "`regionname` VARCHAR(100) NOT NULL," + "PRIMARY KEY (`country`,`region`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; + this->RunQuery(query); + } } if (!this->HasTable(prefix + "server")) { |