Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SQL query time calculation to use Django aggregation #719

Conversation

beltagymohamed
Copy link
Contributor

@beltagymohamed beltagymohamed commented Jul 9, 2024

  • Refactored time_spent_on_sql_queries property in the Request model:
    • Replaced manual summation of time_taken with a Django aggregate query.
  • Updated relevant test case to reflect the changes.

This improves the efficiency of the code.

beltagymohamed and others added 22 commits July 9, 2024 06:17
- Ordered Django model imports alphabetically for better readability.
- Refactored `time_spent_on_sql_queries` property in the `Request` model:
  - Replaced manual summation of `time_taken` with a Django aggregate query.
  - Used `ExpressionWrapper` to calculate the total time spent on SQL queries by subtracting `start_time` from `end_time`.
  - Ensured `None` values are handled gracefully using the `Coalesce` function.
- Updated relevant test case to reflect the changes.

This improves the efficiency and readability of the code."
@beltagymohamed
Copy link
Contributor Author

@albertyw the PR is ready, sorry for the big number of commits and workflow

@webknjaz webknjaz requested a review from albertyw July 16, 2024 16:03
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.

1 participant