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: auto unlock locked tasks after 3 days #1984

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

Anuj-Gupta4
Copy link
Contributor

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation
  • πŸ§‘β€πŸ’» Refactor
  • βœ… Test
  • πŸ€– Build or CI
  • ❓ Other (please specify)

Related Issue

Describe this PR

A new function has been created here that will unlock stale tasks.
There is also an endpoint that will help us test it manually.

Review Guide

Is there a better way to do this without disabling task_event_state_trigger?
Is the logic implemented here correct?

@spwoodcock
Copy link
Member

spwoodcock commented Dec 16, 2024

Sorry for taking so long to review!

Good thinking also accounting for the entities / building unlock, as well as tasks.

Is there any chance we could look into:

  • Only do this for projects with activity in the last week. While we run the cron at a schedule, we should first filter down so we only run the logic on projects with recent activity (did determined from task_events entries is good enough). Of activity, continue to the unlocking logic.

  • Using the updatedAt field that already exists in ODK for entities. I'm not sure we need a new field in our db. I think the ODK entites unlocking can be done via the process:

    1. Call the sync function to sync current status from ODK
    2. If there are any entities that are status 1 (open in ODK), we continue to the unlocking logic.
    3. If we call the ODK API to get entity data, including the updatedAt field (hopefully we can reuse existing functions just using different odata filters, but might need to modify slightly?). Using odata filters we should be able to get entities with updates over 1 day ago, also via the updatedAt field.

The criteria for unlocking can be found in this comment: #1603 (comment)

For the entities unlock, we could probably just base it on: if its 'open in ODK', but no activity in 1hr, then we reset the status.

Does that sound reasonable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code enhancement New feature or request migration Contains a DB migration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically unlock tasks that have been locked for more than 3 days
2 participants