Skip to content

Enhancements to user-related database queries for efficiency and clarity - #17

Closed
arian24b wants to merge 8 commits into
PasarGuard:nextfrom
arian24b:next
Closed

Enhancements to user-related database queries for efficiency and clarity#17
arian24b wants to merge 8 commits into
PasarGuard:nextfrom
arian24b:next

Conversation

@arian24b

@arian24b arian24b commented Oct 4, 2025

Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and code cleanups, focusing primarily on the user database access layer and some project configuration files. The most significant changes are enhancements to user-related database queries for efficiency and clarity, modernization of type hints, and some minor updates to logging and workflow automation.

User Database Query and Model Improvements:

  • Updated user retrieval functions (get_user, get_user_by_id, get_users, and related queries) to eagerly load related fields (groups, admin, next_plan, usage_logs, etc.) using selectinload and joinedload, improving query efficiency and reducing the need for additional attribute loading. Also removed unnecessary calls to load_user_attrs. [1] [2] [3] [4]
  • Replaced deprecated or less precise type hints (such as Optional[User] and List) with modern Python type hints (e.g., User | None, list[User]). [1] [2] [3]
  • Simplified and clarified docstrings for all user-related CRUD functions, making them more concise and consistent. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Standardized usage of the UTC timezone from datetime and removed the unused timezone import, ensuring consistent timezone handling throughout the codebase. [1] [2] [3] [4]

Project Configuration and Workflow:

  • Updated the .github/workflows/ruff-check.yml workflow to use the official astral-sh/ruff-action for linting, simplifying the setup and ensuring better integration with Ruff's latest features.
  • Added .ruff_cache to .dockerignore to prevent unnecessary files from being included in Docker builds.

Other Code Quality Improvements:

  • Improved logging by switching to parameterized logging for version info in app/__init__.py, which is safer and more efficient.
  • Minor logic simplification in the application startup/shutdown sequence in app/__init__.py. [1] [2]

These changes collectively improve code maintainability, performance, and clarity, especially around user data access and project automation.

@ImMohammad20000

Copy link
Copy Markdown
Contributor

your change is not very nesserly
i cant merge it you added so many join load and it not good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants