Systers, an AnitaB.org community

Optimise current backend code with lambda expressions (Backend)

Description:

Review current backend code and see where we can optimise it using lambda expressions. For example replace this

users_list = UserModel.query.filter(UserModel.id != user_id).all()
list_of_users = []
for user in users_list:
    if user.is_email_verified:
    list_of_users += [user.json()]
]

with something like this:

users_list = UserModel.query.filter(UserModel.id != user_id).all()
list_of_users = filter(lambda user: user.is_email_verified, users_list)

Prerequisite:

  • Have a GitHub account
  • Know how to use git
  • Setup and run the project on your local development environment

Action Items:

  • Create a copy of the project into your account GitHub by forking systers/mentorship-backend project.
  • Clone the project onto your local development environment
  • Create a branch to make your changes
  • Optimise the code using lambda expressions.
  • Please make sure all tests pass after changes.
  • Commit your change through the interface using our Commit message Style Guide.
  • Submit a Pull Request, targeting gci-dev branch, following the template provided in the description.

Resources:

Work Submission:

  • Submit a link to Pull Request (PR) created with the change.

Task tags

  • python
  • functional programming
  • code refactoring
  • lambda functions
  • backend

Students who completed this task

_daksha_, asawesome07, HardikJH, i_maier

Task type

  • code Code
close

2019