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

[Quest] Write a service to mark Tasks as expired. #1703

Closed
6 tasks done
dubdabasoduba opened this issue Sep 28, 2022 · 2 comments · Fixed by #1826
Closed
6 tasks done

[Quest] Write a service to mark Tasks as expired. #1703

dubdabasoduba opened this issue Sep 28, 2022 · 2 comments · Fixed by #1826
Assignees
Labels

Comments

@dubdabasoduba
Copy link
Member

dubdabasoduba commented Sep 28, 2022

Enhancement context

  • We currently, only show the overdue tasks. However, some tasks get expired after a certain period of them being overdue
  • These expired tasks can't be performed anymore. We will be tracking the expired tasks by updating the Task.status to cancelled.
  • We will be tracking the expiry date from the Task.restriction.period.end. If the end date is =< today() then the task is expired.

Implementation

  • Write a service to mark tasks as expired. The timing of the service should be at least after every 1 hour.
    • The timing should be configurable on the application_config. In case it's not added then the default is set to 1 hour.
  • The Task.restriction.period.end should be used to determine the task expiry.
    • If the Task.restriction.period.end date =< today() then update the Task.status to cancelled

Acceptance Criteria

  • All the expired tasks should have a status cancelled.
  • The service to update the statuses should run periodically.
@ekigamba
Copy link
Contributor

  • Since this is going to be running every X mins/hours and not every midnight, the job will be scheduled using the WorkManager and might end up reusing most of the work done on [Quest] Background Jobs initiated via scheduled jobs with WorkManager  #1798
  • The Task.restriction is not a search param and therefore the FHIR Engine in the Android FHIR SDK does not allow us to use it to get tasks whose restriction.period.end is below the current date/datetime. Therefore we can either:
    • Run a raw query directly using a separate SQLiteOpenHelper since FHIR Engine does not allow us to run the query. This allows us to run full-scan queries without locking the database and slowing down other reads and writes requested by the app on the foreground.
    • Use the FHIR Engine to get tasks which are neither cancelled nor completed and then add code to check the restriction end dates. This will run on the TokenIndexEntity table using an index. This will reduce the runtime of these queries and minimize the lag introduced

@ekigamba
Copy link
Contributor

ekigamba commented Nov 25, 2022

Remaining: Fix DI in Job and add tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants