This update includes multiple improvements to the crud.py file for the User table:
Optimized get_users_number function by querying the indexed username 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 and setattr, reducing multiple if statements and improving maintainability.
This update includes multiple improvements to the
crud.py
file for theUser
table:get_users_number
function by querying the indexedusername
field, improving performance when counting users.get_users_with_pagination
function to combine user retrieval and birthdate formatting using a list comprehension for cleaner code and enhanced performance.get_user_if_contains_username
function to use a list comprehension for formatting birthdates, leading to cleaner code and potential performance gains.edit_user
function to dynamically update user fields using a dictionary andsetattr
, reducing multipleif
statements and improving maintainability.