diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index 2c9a6445..7c1c2bb7 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -13,7 +13,6 @@ "database": "src/modules/database/database.json", "level": "src/modules/level/level.json", "permission": "src/modules/permission/permission.json", - "stats": "src/modules/stats/stats.json", "technician": "src/modules/technician/technician.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index d9f9ef16..d7d6a2d7 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -19,7 +19,7 @@ "cpl-core==2022.12.1.post3", "cpl-translation==2022.12.1", "cpl-query==2022.12.2.post1", - "Flask==2.2.3", + "Flask==2.2.2", "Flask-Classful==0.14.2", "Flask-Cors==3.0.10", "PyJWT==2.6.0", @@ -41,15 +41,15 @@ "BuildSettings": { "ProjectType": "console", "SourcePath": "", - "OutputPath": "..\\..\\dist", + "OutputPath": "../../dist", "Main": "bot.main", "EntryPoint": "bot", "IncludePackageData": false, "Included": [], "Excluded": [ - "*\\__pycache__", - "*\\logs", - "*\\tests" + "*/__pycache__", + "*/logs", + "*/tests" ], "PackageData": {}, "ProjectReferences": [ @@ -63,7 +63,6 @@ "../modules/database/database.json", "../modules/level/level.json", "../modules/permission/permission.json", - "../modules/stats/stats.json", "../modules/technician/technician.json" ] } diff --git a/kdb-bot/src/bot/startup_migration_extension.py b/kdb-bot/src/bot/startup_migration_extension.py index a6b13ddd..80b0d966 100644 --- a/kdb-bot/src/bot/startup_migration_extension.py +++ b/kdb-bot/src/bot/startup_migration_extension.py @@ -10,6 +10,7 @@ from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration from bot_data.migration.auto_role_migration import AutoRoleMigration from bot_data.migration.initial_migration import InitialMigration from bot_data.migration.level_migration import LevelMigration +from bot_data.migration.remove_stats_migration import RemoveStatsMigration from bot_data.migration.stats_migration import StatsMigration from bot_data.migration.user_joined_game_server_migration import UserJoinedGameServerMigration from bot_data.migration.user_message_count_per_hour_migration import ( @@ -36,3 +37,4 @@ class StartupMigrationExtension(StartupExtensionABC): services.add_transient(MigrationABC, UserMessageCountPerHourMigration) # 11.01.2023 #168 - 0.3.1 services.add_transient(MigrationABC, ApiKeyMigration) # 09.02.2023 #162 - 1.0.0 services.add_transient(MigrationABC, UserJoinedGameServerMigration) # 12.02.2023 #181 - 1.0.0 + services.add_transient(MigrationABC, RemoveStatsMigration) # 19.02.2023 #190 - 1.0.0 diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py index c5312cdf..50945c4e 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py @@ -15,7 +15,6 @@ class FeatureFlagsEnum(Enum): level_module = "LevelModule" moderator_module = "ModeratorModule" permission_module = "PermissionModule" - stats_module = "StatsModule" # features api_only = "ApiOnly" presence = "Presence" diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py index 966b746e..0b34969c 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py @@ -24,7 +24,6 @@ class FeatureFlagsSettings(ConfigurationModelABC): FeatureFlagsEnum.database_module.value: True, # 02.10.2022 #48 FeatureFlagsEnum.moderator_module.value: False, # 02.10.2022 #48 FeatureFlagsEnum.permission_module.value: True, # 02.10.2022 #48 - FeatureFlagsEnum.stats_module.value: True, # 08.11.2022 #46 # features FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70 FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56 diff --git a/kdb-bot/src/bot_data/migration/remove_stats_migration.py b/kdb-bot/src/bot_data/migration/remove_stats_migration.py new file mode 100644 index 00000000..bbc029b5 --- /dev/null +++ b/kdb-bot/src/bot_data/migration/remove_stats_migration.py @@ -0,0 +1,43 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class RemoveStatsMigration(MigrationABC): + name = "1.0_RemoveStatsMigration" + + def __init__(self, logger: DatabaseLogger, db: DBContext): + MigrationABC.__init__(self) + self._logger = logger + self._db = db + self._cursor = db.cursor + + def upgrade(self): + self._logger.debug(__name__, "Running upgrade") + + self._cursor.execute( + str( + f""" + DROP TABLE IF EXISTS `Statistics`; + """ + ) + ) + + def downgrade(self): + self._cursor.execute( + str( + f""" + CREATE TABLE IF NOT EXISTS `Statistics` ( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `Name` VARCHAR(255) NOT NULL, + `Description` VARCHAR(255) NOT NULL, + `Code` LONGTEXT NOT NULL, + `ServerId` BIGINT, + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), + PRIMARY KEY(`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`) + ); + """ + ) + ) diff --git a/kdb-bot/src/bot_data/migration/stats_migration.py b/kdb-bot/src/bot_data/migration/stats_migration.py index b5bb0715..c28eeda9 100644 --- a/kdb-bot/src/bot_data/migration/stats_migration.py +++ b/kdb-bot/src/bot_data/migration/stats_migration.py @@ -4,7 +4,7 @@ from bot_data.db_context import DBContext class StatsMigration(MigrationABC): - name = "1.0_RemoveStatsMigration" + name = "0.3_StatsMigration" def __init__(self, logger: DatabaseLogger, db: DBContext): MigrationABC.__init__(self) @@ -18,26 +18,20 @@ class StatsMigration(MigrationABC): self._cursor.execute( str( f""" - DROP TABLE IF EXISTS `Statistics`; - """ + CREATE TABLE IF NOT EXISTS `Statistics` ( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `Name` VARCHAR(255) NOT NULL, + `Description` VARCHAR(255) NOT NULL, + `Code` LONGTEXT NOT NULL, + `ServerId` BIGINT, + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), + PRIMARY KEY(`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`) + ); + """ ) ) def downgrade(self): - self._cursor.execute( - str( - f""" - CREATE TABLE IF NOT EXISTS `Statistics` ( - `Id` BIGINT NOT NULL AUTO_INCREMENT, - `Name` VARCHAR(255) NOT NULL, - `Description` VARCHAR(255) NOT NULL, - `Code` LONGTEXT NOT NULL, - `ServerId` BIGINT, - `CreatedAt` DATETIME(6), - `LastModifiedAt` DATETIME(6), - PRIMARY KEY(`Id`), - FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`) - ); - """ - ) - ) + self._cursor.execute("DROP TABLE `Statistics`;")