Added setting for max steam offer count
This commit is contained in:
@@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory`
|
||||
`WaitForRestart` BIGINT NOT NULL DEFAULT 8,
|
||||
`WaitForShutdown` BIGINT NOT NULL DEFAULT 8,
|
||||
`CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000,
|
||||
`MaxSteamOfferCount` BIGINT NOT NULL DEFAULT 250,
|
||||
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||
`Deleted` BOOL DEFAULT FALSE,
|
||||
`DateFrom` DATETIME(6) NOT NULL,
|
||||
@@ -23,6 +24,7 @@ BEGIN
|
||||
`WaitForRestart`,
|
||||
`WaitForShutdown`,
|
||||
`CacheMaxMessages`,
|
||||
`MaxSteamOfferCount`,
|
||||
`FeatureFlags`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
@@ -31,6 +33,7 @@ BEGIN
|
||||
OLD.WaitForRestart,
|
||||
OLD.WaitForShutdown,
|
||||
OLD.CacheMaxMessages,
|
||||
OLD.MaxSteamOfferCount,
|
||||
OLD.FeatureFlags,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
@@ -48,6 +51,7 @@ BEGIN
|
||||
`WaitForRestart`,
|
||||
`WaitForShutdown`,
|
||||
`CacheMaxMessages`,
|
||||
`MaxSteamOfferCount`,
|
||||
`FeatureFlags`,
|
||||
`Deleted`,
|
||||
`DateFrom`,
|
||||
@@ -57,6 +61,7 @@ BEGIN
|
||||
OLD.WaitForRestart,
|
||||
OLD.WaitForShutdown,
|
||||
OLD.CacheMaxMessages,
|
||||
OLD.MaxSteamOfferCount,
|
||||
OLD.FeatureFlags,
|
||||
TRUE,
|
||||
OLD.LastModifiedAt,
|
||||
|
@@ -0,0 +1,51 @@
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_data.abc.migration_abc import MigrationABC
|
||||
from bot_data.db_context import DBContext
|
||||
|
||||
|
||||
class MaxSteamOfferCountMigration(MigrationABC):
|
||||
name = "1.2.0_MaxSteamOfferCountMigration"
|
||||
|
||||
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"""
|
||||
ALTER TABLE CFG_Technician
|
||||
ADD MaxSteamOfferCount BIGINT NOT NULL DEFAULT 250 AFTER CacheMaxMessages;
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_TechnicianHistory
|
||||
ADD MaxSteamOfferCount BIGINT NOT NULL DEFAULT 250 AFTER CacheMaxMessages;
|
||||
"""
|
||||
)
|
||||
)
|
||||
self._exec(__file__, "config/technician.sql")
|
||||
|
||||
def downgrade(self):
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_Technician DROP COLUMN MaxSteamOfferCount;
|
||||
"""
|
||||
)
|
||||
)
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_TechnicianHistory DROP COLUMN MaxSteamOfferCount;
|
||||
"""
|
||||
)
|
||||
)
|
@@ -15,6 +15,7 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
wait_for_restart: int,
|
||||
wait_for_shutdown: int,
|
||||
cache_max_messages: int,
|
||||
max_steam_offer_count: int,
|
||||
feature_flags: dict[FeatureFlagsEnum],
|
||||
technician_ids: List[int],
|
||||
ping_urls: List[str],
|
||||
@@ -27,6 +28,7 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
self._wait_for_restart = wait_for_restart
|
||||
self._wait_for_shutdown = wait_for_shutdown
|
||||
self._cache_max_messages = cache_max_messages
|
||||
self._max_steam_offer_count = max_steam_offer_count
|
||||
self._feature_flags = feature_flags
|
||||
self._technician_ids = technician_ids
|
||||
self._ping_urls = ping_urls
|
||||
@@ -71,6 +73,14 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
def cache_max_messages(self, value: int):
|
||||
self._cache_max_messages = value
|
||||
|
||||
@property
|
||||
def max_steam_offer_count(self) -> int:
|
||||
return self._max_steam_offer_count
|
||||
|
||||
@max_steam_offer_count.setter
|
||||
def max_steam_offer_count(self, value: int):
|
||||
self._max_steam_offer_count = value
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[FeatureFlagsEnum]:
|
||||
return self._feature_flags
|
||||
@@ -117,12 +127,13 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
return str(
|
||||
f"""
|
||||
INSERT INTO `CFG_Technician` (
|
||||
`HelpCommandReferenceUrl`, `WaitForRestart`, `WaitForShutdown`, `CacheMaxMessages`, `FeatureFlags`
|
||||
`HelpCommandReferenceUrl`, `WaitForRestart`, `WaitForShutdown`, `CacheMaxMessages`, `MaxSteamOfferCount`, `FeatureFlags`
|
||||
) VALUES (
|
||||
'{self._help_command_reference_url}',
|
||||
{self._wait_for_restart},
|
||||
{self._wait_for_shutdown},
|
||||
{self._cache_max_messages},
|
||||
{self._max_steam_offer_count},
|
||||
'{json.dumps(self._feature_flags)}'
|
||||
);
|
||||
"""
|
||||
@@ -137,6 +148,7 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
`WaitForRestart` = {self._wait_for_restart},
|
||||
`WaitForShutdown` = {self._wait_for_shutdown},
|
||||
`CacheMaxMessages` = {self._cache_max_messages},
|
||||
`MaxSteamOfferCount` = {self._max_steam_offer_count},
|
||||
`FeatureFlags` = '{json.dumps(self._feature_flags)}'
|
||||
WHERE `Id` = {self._id};
|
||||
"""
|
||||
|
@@ -46,11 +46,12 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC):
|
||||
result[2],
|
||||
result[3],
|
||||
result[4],
|
||||
json.loads(result[5]),
|
||||
result[5],
|
||||
json.loads(result[6]),
|
||||
self._get_technician_ids(),
|
||||
self._get_technician_ping_urls(),
|
||||
result[6],
|
||||
result[7],
|
||||
result[8],
|
||||
id=result[0],
|
||||
)
|
||||
|
||||
|
72
bot/src/bot_data/startup_migration_extension.py
Normal file
72
bot/src/bot_data/startup_migration_extension.py
Normal file
@@ -0,0 +1,72 @@
|
||||
from cpl_core.application import StartupExtensionABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironmentABC
|
||||
|
||||
from bot_data.abc.migration_abc import MigrationABC
|
||||
from bot_data.migration.achievements_migration import AchievementsMigration
|
||||
from bot_data.migration.api_key_migration import ApiKeyMigration
|
||||
from bot_data.migration.api_migration import ApiMigration
|
||||
from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration
|
||||
from bot_data.migration.auto_role_migration import AutoRoleMigration
|
||||
from bot_data.migration.birthday_migration import BirthdayMigration
|
||||
from bot_data.migration.config_feature_flags_migration import (
|
||||
ConfigFeatureFlagsMigration,
|
||||
)
|
||||
from bot_data.migration.config_migration import ConfigMigration
|
||||
from bot_data.migration.db_history_migration import DBHistoryMigration
|
||||
from bot_data.migration.default_role_migration import DefaultRoleMigration
|
||||
from bot_data.migration.fix_updates_migration import FixUpdatesMigration
|
||||
from bot_data.migration.fix_user_history_migration import FixUserHistoryMigration
|
||||
from bot_data.migration.initial_migration import InitialMigration
|
||||
from bot_data.migration.level_migration import LevelMigration
|
||||
from bot_data.migration.max_steam_offer_count_migration import MaxSteamOfferCountMigration
|
||||
from bot_data.migration.remove_stats_migration import RemoveStatsMigration
|
||||
from bot_data.migration.short_role_name_migration import ShortRoleNameMigration
|
||||
from bot_data.migration.short_role_name_only_highest_migration import (
|
||||
ShortRoleNameOnlyHighestMigration,
|
||||
)
|
||||
from bot_data.migration.stats_migration import StatsMigration
|
||||
from bot_data.migration.steam_special_offer_migration import SteamSpecialOfferMigration
|
||||
from bot_data.migration.user_joined_game_server_migration import (
|
||||
UserJoinedGameServerMigration,
|
||||
)
|
||||
from bot_data.migration.user_message_count_per_hour_migration import (
|
||||
UserMessageCountPerHourMigration,
|
||||
)
|
||||
from bot_data.migration.user_warning_migration import UserWarningMigration
|
||||
from bot_data.service.migration_service import MigrationService
|
||||
|
||||
|
||||
class StartupMigrationExtension(StartupExtensionABC):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
|
||||
pass
|
||||
|
||||
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
|
||||
services.add_transient(MigrationService)
|
||||
services.add_transient(MigrationABC, InitialMigration)
|
||||
services.add_transient(MigrationABC, AutoRoleMigration) # 03.10.2022 #54 - 0.2.2
|
||||
services.add_transient(MigrationABC, ApiMigration) # 15.10.2022 #70 - 0.3.0
|
||||
services.add_transient(MigrationABC, LevelMigration) # 06.11.2022 #25 - 0.3.0
|
||||
services.add_transient(MigrationABC, StatsMigration) # 09.11.2022 #46 - 0.3.0
|
||||
services.add_transient(MigrationABC, AutoRoleFix1Migration) # 30.12.2022 #151 - 0.3.0
|
||||
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
|
||||
services.add_transient(MigrationABC, UserWarningMigration) # 21.02.2023 #35 - 1.0.0
|
||||
services.add_transient(MigrationABC, DBHistoryMigration) # 06.03.2023 #246 - 1.0.0
|
||||
services.add_transient(MigrationABC, AchievementsMigration) # 14.06.2023 #268 - 1.1.0
|
||||
services.add_transient(MigrationABC, ConfigMigration) # 19.07.2023 #127 - 1.1.0
|
||||
services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0
|
||||
services.add_transient(MigrationABC, DefaultRoleMigration) # 24.09.2023 #360 - 1.1.3
|
||||
services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7
|
||||
services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7
|
||||
services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9
|
||||
services.add_transient(MigrationABC, FixUserHistoryMigration) # 10.10.2023 #401 - 1.2.0
|
||||
services.add_transient(MigrationABC, BirthdayMigration) # 10.10.2023 #401 - 1.2.0
|
||||
services.add_transient(MigrationABC, SteamSpecialOfferMigration) # 10.10.2023 #188 - 1.2.0
|
||||
services.add_transient(MigrationABC, MaxSteamOfferCountMigration) # 04.11.2023 #188 - 1.2.0
|
Reference in New Issue
Block a user