The idea is to optimize query of unverified users, so that these are fetched directly from the database instead of fetching all and then filtering with python code.
In this line https://github.com/anitab-org/mentorship-backend/blob/develop/app/schedulers/delete_unverified_users_cron_job.py#L20 you can see the code fetches the all users fro UserModel and only then it filters non verified users
UserModel instead of from the list of users returned from it.1 hour
@isabelcosta If this issue is available. Can I work on it?
@PareenKarpe yes you can :) I just assigned this to you
@isabelcosta I am replacing the above query with the below
unverified_users = list(
UserModel.query.filter_by(is_email_verified=False).all()
)
@isabelcosta I have committed the changes on my fork branch. But I am not sure how exactly I can test it as its a cron job. Can you help me with it? So after testing I can create a pull request for my committed changes
@PareenKarpe your code suggestion is totally correct :D
If you wish you can already send the PR, even if in a work in progress state.
In terms of testing, I would say you can reduce the timing of the cron job for 1 min for example, and have a couple of users verified and not verified in the database (e.g.: 1 user with email verified and 2 with email not verified, after that cron job execution you should only have the first user).
How does this sound?
@isabelcosta Sure it sounds good. I am trying to test it. But every time I am registering a user I get 500 response and this error at the terminal
return self.digest_method(salt + b"signer" + self.secret_key).digest()
TypeError: can't concat NoneType to bytes
I am missing something with this. Can you help me with it?
@PareenKarpe have you set the environment variables? That might be the issue.
馃憠 https://github.com/anitab-org/mentorship-backend/blob/develop/docs/environment-variables.md
@isabelcosta I am doing it the same way mentioned in the link. I will check it again
@isabelcosta Thank a lot for helping. I was passing in the wrong format without the quotes. The query works and only deletes users who are not with verified emails. I am sending the PR request for the commit.
Yey! 馃帀 I'm so happy you managed to do this and test it properly 馃憦 馃憦 @PareenKarpe