mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-06-05 20:09:37 +00:00
Add configurable minimum refresh interval setting
Added user-configurable minimum refresh interval for inventory reloads, allowing users to control how frequently the maintenance service triggers updates (default: 30 minutes, range: 1-1440 minutes). - Add minimum_refresh_interval_minutes to settings system with default of 30 minutes - Update maintenance service to use configurable interval instead of hardcoded 1-minute value - Add GUI input field in General Settings with auto-save functionality - Include field in API settings endpoint and settings manager 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ class SettingsFile(TypedDict):
|
||||
autostart_tray: bool
|
||||
connection_quality: int
|
||||
tray_notifications: bool
|
||||
minimum_refresh_interval_minutes: int
|
||||
|
||||
|
||||
default_settings: SettingsFile = {
|
||||
@@ -30,6 +31,7 @@ default_settings: SettingsFile = {
|
||||
"connection_quality": 1,
|
||||
"language": DEFAULT_LANG,
|
||||
"tray_notifications": True,
|
||||
"minimum_refresh_interval_minutes": 30,
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +52,7 @@ class Settings:
|
||||
autostart_tray: bool
|
||||
connection_quality: int
|
||||
tray_notifications: bool
|
||||
minimum_refresh_interval_minutes: int
|
||||
|
||||
PASSTHROUGH = ("_settings", "_args", "_altered")
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class MaintenanceService:
|
||||
3. After reaching the next hour boundary, request inventory reload
|
||||
"""
|
||||
now = datetime.now(timezone.utc)
|
||||
next_period = now + timedelta(minutes=1)
|
||||
next_period = now + timedelta(minutes=self._twitch.settings.minimum_refresh_interval_minutes)
|
||||
|
||||
while True:
|
||||
# exit if there's no need to repeat the loop
|
||||
@@ -89,6 +89,6 @@ class MaintenanceService:
|
||||
logger.log(CALL, "Maintenance task requests channels cleanup")
|
||||
self._twitch.change_state(State.CHANNELS_CLEANUP)
|
||||
|
||||
# this triggers a restart of this task every (up to) 60 minutes
|
||||
# this triggers a restart of this task every (up to) <timedelta> minutes
|
||||
logger.log(CALL, "Maintenance task requests a reload")
|
||||
self._twitch.change_state(State.INVENTORY_FETCH)
|
||||
|
||||
@@ -76,6 +76,7 @@ class SettingsUpdate(BaseModel):
|
||||
proxy: str | None = None
|
||||
tray_notifications: bool | None = None
|
||||
connection_quality: int | None = None
|
||||
minimum_refresh_interval_minutes: int | None = None
|
||||
|
||||
|
||||
# ==================== REST API Endpoints ====================
|
||||
|
||||
@@ -38,7 +38,8 @@ class SettingsManager:
|
||||
"games_available": self._available_games,
|
||||
"proxy": str(self._settings.proxy),
|
||||
"tray_notifications": self._settings.tray_notifications,
|
||||
"connection_quality": self._settings.connection_quality
|
||||
"connection_quality": self._settings.connection_quality,
|
||||
"minimum_refresh_interval_minutes": self._settings.minimum_refresh_interval_minutes
|
||||
}
|
||||
|
||||
def update_settings(self, settings_data: dict[str, Any]):
|
||||
@@ -57,6 +58,8 @@ class SettingsManager:
|
||||
self._settings.proxy = settings_data["proxy"]
|
||||
if "tray_notifications" in settings_data:
|
||||
self._settings.tray_notifications = settings_data["tray_notifications"]
|
||||
if "minimum_refresh_interval_minutes" in settings_data:
|
||||
self._settings.minimum_refresh_interval_minutes = settings_data["minimum_refresh_interval_minutes"]
|
||||
self._settings.alter()
|
||||
asyncio.create_task(
|
||||
self._broadcaster.emit("settings_updated", self.get_settings())
|
||||
|
||||
Reference in New Issue
Block a user