endurain
endurain copied to clipboard
optimize users's crud.py database queries
This update includes multiple improvements to the crud.py
file for the User
table:
-
Optimized
get_users_number
function by querying the indexedusername
field, improving performance when counting users. -
Refactored
get_users_with_pagination
function to combine user retrieval and birthdate formatting using a list comprehension for cleaner code and enhanced performance. -
Refactored
get_user_if_contains_username
function to use a list comprehension for formatting birthdates, leading to cleaner code and potential performance gains. -
Refactored
edit_user
function to dynamically update user fields using a dictionary andsetattr
, reducing multipleif
statements and improving maintainability.