Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(task-processor): Add recurring task to clean password reset #3153

Merged
merged 3 commits into from
Dec 20, 2023

Conversation

gagantrivedi
Copy link
Member

@gagantrivedi gagantrivedi commented Dec 13, 2023

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Create a recurring task to clean-up UserPasswordResetRequest table
closes #2649

How did you test this code?

Adds unit test cases

@github-actions github-actions bot added the api Issue related to the REST API label Dec 13, 2023
Copy link

vercel bot commented Dec 13, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2023 1:15pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2023 1:15pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2023 1:15pm

@@ -21,7 +22,7 @@

logger = logging.getLogger(__name__)

TASKS_MODULES_TO_RELOAD = [processor_tasks, sse_tasks]
TASKS_MODULES_TO_RELOAD = [processor_tasks, sse_tasks, auth_tasks]
Copy link
Member Author

@gagantrivedi gagantrivedi Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add auth_tasks here because that module is not imported by anything, i.e: python will not load it otherwise... It's not perfect, please feel free to suggest a better idea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's considered good practice to use AppConfig.ready() for such cases, e.g.

# custom_auth/apps.py

class CustomAuthAppConfig(AppConfig):
    name = "custom_auth"
   
    def ready(self) -> None:
        from custom_auth import tasks
# settings/common.py

...

INSTALLED_APPS = [
    ...
    "custom_auth",
    ...
]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the phrased the comment wrong, we need a way to load it but not before we set RUN_BY_PROCESSOR. Importing tasks in ready will mean that we need to reload tasks here anyway

Copy link
Member

@khvn26 khvn26 Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd set RUN_BY_PROCESSOR outside the command then, e.g. in the run_task_processor function in the entrypoint script. Seems less hacky this way.

Copy link
Member Author

@gagantrivedi gagantrivedi Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a great idea! I wonder why it was not implemented like this in the first place

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@gagantrivedi gagantrivedi requested review from a team and novakzaballa and removed request for a team December 13, 2023 10:51
Copy link
Contributor

github-actions bot commented Dec 13, 2023

Uffizzi Preview deployment-42710 was deleted.

@gagantrivedi gagantrivedi requested a review from khvn26 December 15, 2023 08:09
@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (068253e) 96.08% compared to head (7657993) 96.02%.
Report is 40 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3153      +/-   ##
==========================================
- Coverage   96.08%   96.02%   -0.07%     
==========================================
  Files        1054     1062       +8     
  Lines       31702    32220     +518     
==========================================
+ Hits        30462    30938     +476     
- Misses       1240     1282      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gagantrivedi gagantrivedi added this pull request to the merge queue Dec 20, 2023
Merged via the queue into main with commit 6898253 Dec 20, 2023
18 checks passed
@gagantrivedi gagantrivedi deleted the fix/2649/cleanup-user-password-request branch December 20, 2023 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a recurring task to clear UserPasswordResetRequest
3 participants