endurain icon indicating copy to clipboard operation
endurain copied to clipboard

optimize users's crud.py database queries

Open movassaghi6 opened this issue 5 months ago • 0 comments

This update includes multiple improvements to the crud.py file for the User table:

  1. Optimized get_users_number function by querying the indexed username field, improving performance when counting users.
  2. Refactored get_users_with_pagination function to combine user retrieval and birthdate formatting using a list comprehension for cleaner code and enhanced performance.
  3. Refactored get_user_if_contains_username function to use a list comprehension for formatting birthdates, leading to cleaner code and potential performance gains.
  4. Refactored edit_user function to dynamically update user fields using a dictionary and setattr, reducing multiple if statements and improving maintainability.

movassaghi6 avatar Sep 21 '24 09:09 movassaghi6