teresantns / DesafioConstrudelas

Final project for the Construdelas academy, in which I built a loyalty program API
1 stars 0 forks source link

Function to delete expired referrals #8

Closed teresantns closed 2 years ago

teresantns commented 2 years ago

The referrals need to be valid for only 30 days. After that, the referred user cannot accept the invitation anymore, and is free to be referred by another user.

So we need a function to delete referrals that are older than 30 days This function should be called before: (all endpoints, basically)

This can be later automated with a cronjob or a library like Celery

This can be a future enhancement of this project, if the deadline allows it.

teresantns commented 2 years ago

Some considerations about the function

If we wish to keep these instances for a data analysis purpose, we could change the logic to include a choice field instead of the boolean status field: we could have three choices: Accepted, Pending and Expired. This way, when the referral expires, it is not removed from the database. This would require some changes into the creating referral logic, to prevent that expired referrals can be accepted, and the target_cpf field would have to be non unique, since a user could have multiple referrals towards them (if the existing ones are expired).