Skip to content

Commit

Permalink
Merge pull request #480 from LionelColaso/toggle_steamdb_notification
Browse files Browse the repository at this point in the history
Move Workshop database expiry to Database Tab
  • Loading branch information
LionelColaso authored Jul 17, 2024
2 parents 0db964f + d4e27d7 commit 68ffead
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
8 changes: 2 additions & 6 deletions app/controllers/settings_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ def _update_view_from_model(self) -> None:
self.settings.external_steam_metadata_repo
)
self.settings_dialog.steam_workshop_db_github_url.setCursorPosition(0)
self.settings_dialog.database_expiry.setText(str(self.settings.database_expiry))

# Sorting tab
if self.settings.sorting_algorithm == SortMethod.ALPHABETICAL:
Expand All @@ -440,9 +441,6 @@ def _update_view_from_model(self) -> None:
self.settings_dialog.db_builder_update_instead_of_overwriting_checkbox.setChecked(
self.settings.build_steam_database_update_toggle
)
self.settings_dialog.db_builder_database_expiry.setText(
str(self.settings.database_expiry)
)
self.settings_dialog.db_builder_steam_api_key.setText(
self.settings.steam_apikey
)
Expand Down Expand Up @@ -564,6 +562,7 @@ def _update_model_from_view(self) -> None:
self.settings.external_steam_metadata_file_path = (
self.settings_dialog.steam_workshop_db_local_file.text()
)
self.settings.database_expiry = int(self.settings_dialog.database_expiry.text())

# Sorting tab
if self.settings_dialog.sorting_alphabetical_radio.isChecked():
Expand All @@ -580,9 +579,6 @@ def _update_model_from_view(self) -> None:
self.settings_dialog.db_builder_query_dlc_checkbox.isChecked()
)
self.settings.build_steam_database_update_toggle = self.settings_dialog.db_builder_update_instead_of_overwriting_checkbox.isChecked()
self.settings.database_expiry = int(
self.settings_dialog.db_builder_database_expiry.text()
)
self.settings.steam_apikey = (
self.settings_dialog.db_builder_steam_api_key.text()
)
Expand Down
2 changes: 1 addition & 1 deletion app/models/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self) -> None:
self.external_community_rules_repo: str = (
"https://github.com/RimSort/Community-Rules-Database"
)
self.database_expiry: int = 604800 # 7 days

# Sorting
self.sorting_algorithm: SortMethod = SortMethod.ALPHABETICAL
Expand All @@ -49,7 +50,6 @@ def __init__(self) -> None:
self.db_builder_include: str = "all_mods"
self.build_steam_database_dlc_data: bool = True
self.build_steam_database_update_toggle: bool = False
self.database_expiry: int = 604800
self.steam_apikey: str = ""

# SteamCMD
Expand Down
15 changes: 8 additions & 7 deletions app/utils/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,14 @@ def get_configured_steam_db(
)
else: # If the cached db data is expired but NOT missing
# Fallback to the expired metadata
self.show_warning_signal.emit(
"Steam DB metadata expired",
"Steam DB is expired! Consider updating!\n",
f'Steam DB last updated: {strftime("%Y-%m-%d %H:%M:%S", localtime(db_data["version"] - life))}\n\n'
+ "Falling back to cached, but EXPIRED Steam Database...",
"",
)
if life != 0: # Disable Notification if value is 0
self.show_warning_signal.emit(
"Steam DB metadata expired",
"Steam DB is expired! Consider updating!\n",
f'Steam DB last updated: {strftime("%Y-%m-%d %H:%M:%S", localtime(db_data["version"] - life))}\n\n'
+ "Falling back to cached, but EXPIRED Steam Database...",
"",
)
db_json_data = db_data[
"database"
] # TODO: additional check to verify integrity of this data's schema
Expand Down
23 changes: 10 additions & 13 deletions app/views/settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ def _do_steam_workshop_db_group(self, tab_layout: QBoxLayout) -> None:
info_label.setWordWrap(True)
item_layout.addWidget(info_label)

database_expiry_label = QLabel(
"Steam Workshop database expiry in Epoch Time (Use 0 to Disable Notificatiom, Default is 7 Days)"
)
group_layout.addWidget(database_expiry_label)

self.database_expiry = QLineEdit()
self.database_expiry.setTextMargins(GUIInfo().text_field_margins)
self.database_expiry.setFixedHeight(GUIInfo().default_font_line_height * 2)
group_layout.addWidget(self.database_expiry)

def _do_sorting_tab(self) -> None:
tab = QWidget()
self.tab_widget.addTab(tab, "Sorting")
Expand Down Expand Up @@ -551,19 +561,6 @@ def _do_db_builder_tab(self) -> None:
group_layout = QGridLayout()
group_box.setLayout(group_layout)

database_expiry_label = QLabel("Database expiry:")
group_layout.addWidget(database_expiry_label, 0, 0)

self.db_builder_database_expiry = QLineEdit()
self.db_builder_database_expiry.setTextMargins(GUIInfo().text_field_margins)
self.db_builder_database_expiry.setFixedHeight(
GUIInfo().default_font_line_height * 2
)
self.db_builder_database_expiry.setFixedWidth(
GUIInfo().default_font_average_char_width * 10
)
group_layout.addWidget(self.db_builder_database_expiry, 0, 1)

steam_api_key_label = QLabel("Steam API key:")
group_layout.addWidget(steam_api_key_label, 1, 0)

Expand Down

0 comments on commit 68ffead

Please sign in to comment.