Skip to content

Commit

Permalink
fix: status page and update
Browse files Browse the repository at this point in the history
## Summary by Sourcery

Update the Docker base image to `5hojib/aeon:beta`. Simplify the upstream repository configuration by prioritizing configuration file values over environment variables, and falling back to the default `https://github.com/AeonOrg/Aeon-MLTB` repository and `main` branch if neither is set. Improve error handling in the update script by catching all exceptions when loading the configuration file. Remove the unused `SEARCH_LIMIT` setting and update the status page UI to dynamically generate buttons for filtering by status.

Bug Fixes:

- Fix an issue where the status page would not display all available statuses when there were more than 20 tasks.

Enhancements:

- Simplify the upstream repository configuration logic.
  • Loading branch information
5hojib authored Jan 26, 2025
1 parent e023f38 commit 55346eb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 56 deletions.
42 changes: 0 additions & 42 deletions CHANGELOG.md

This file was deleted.

2 changes: 0 additions & 2 deletions bot/core/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def load(cls):
"BASE_URL",
"RCLONE_SERVE_URL",
"INDEX_URL",
"SEARCH_API_LINK",
]
and value
):
Expand All @@ -130,7 +129,6 @@ def load_dict(cls, config_dict):
"BASE_URL",
"RCLONE_SERVE_URL",
"INDEX_URL",
"SEARCH_API_LINK",
]
and value
):
Expand Down
2 changes: 2 additions & 0 deletions bot/helper/ext_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step=
if status != "All" or tasks_no > 20:
for label, status_value in list(STATUSES.items()):
if status_value != status:
if not buttons:
buttons = ButtonMaker()
buttons.data_button(label, f"status {sid} st {status_value}")
button = buttons.build_menu(8) if buttons else None
msg += f"<b>CPU:</b> {cpu_percent()}% | <b>FREE:</b> {get_readable_file_size(disk_usage(Config.DOWNLOAD_DIR).free)}"
Expand Down
9 changes: 2 additions & 7 deletions bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"DOWNLOAD_DIR": "/usr/src/app/downloads/",
"LEECH_SPLIT_SIZE": TgClient.MAX_SPLIT_SIZE,
"RSS_DELAY": 600,
"SEARCH_LIMIT": 0,
"UPSTREAM_BRANCH": "main",
"DEFAULT_UPLOAD": "rc",
}
Expand Down Expand Up @@ -204,9 +203,7 @@ async def edit_variable(_, message, pre_message, key):
await update_buttons(pre_message, "var")
await delete_message(message)
await database.update_config({key: value})
if key in ["SEARCH_PLUGINS", "SEARCH_API_LINK"]:
await initiate_search_tools()
elif key in ["QUEUE_ALL", "QUEUE_DOWNLOAD", "QUEUE_UPLOAD"]:
if key in ["QUEUE_ALL", "QUEUE_DOWNLOAD", "QUEUE_UPLOAD"]:
await start_from_queued()
elif key in [
"RCLONE_SERVE_URL",
Expand Down Expand Up @@ -392,9 +389,7 @@ async def edit_bot_settings(client, query):
if data[2] == "DATABASE_URL":
await database.disconnect()
await database.update_config({data[2]: value})
if data[2] in ["SEARCH_PLUGINS", "SEARCH_API_LINK"]:
await initiate_search_tools()
elif data[2] in ["QUEUE_ALL", "QUEUE_DOWNLOAD", "QUEUE_UPLOAD"]:
if data[2] in ["QUEUE_ALL", "QUEUE_DOWNLOAD", "QUEUE_UPLOAD"]:
await start_from_queued()
elif data[2] in [
"RCLONE_SERVE_URL",
Expand Down
15 changes: 10 additions & 5 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def format(self, record: LogRecord) -> str:
key: value.strip() if isinstance(value, str) else value
for key, value in vars(settings).items()
}
except ModuleNotFoundError:
except Exception:
log_error(
"The 'config.py' file is missing! Falling back to environment variables.",
)
Expand Down Expand Up @@ -106,12 +106,17 @@ def format(self, record: LogRecord) -> str:
except Exception as e:
log_error(f"Database ERROR: {e}")

UPSTREAM_REPO = config_file.get(
"UPSTREAM_REPO",
"https://github.com/AeonOrg/Aeon-MLTB",
UPSTREAM_REPO = (
config_file.get("UPSTREAM_REPO", "")
or os.getenv("UPSTREAM_REPO", "")
or "https://github.com/AeonOrg/Aeon-MLTB"
)

UPSTREAM_BRANCH = config_file.get("UPSTREAM_BRANCH", "") or "main"
UPSTREAM_BRANCH = (
config_file.get("UPSTREAM_BRANCH", "")
or os.getenv("UPSTREAM_BRANCH", "")
or "main"
)

if UPSTREAM_REPO:
if path.exists(".git"):
Expand Down

0 comments on commit 55346eb

Please sign in to comment.