-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Update API to use events and task states + fixes to backend refactor #1838
Conversation
Would you merge this PR to dev first or should I make a branch from your branch? |
@spwoodcock One thing you missed in the previous PR I guess to update the |
If you could branch from branch for today, I'll also continue to tweak the backend today & hopefully get that part done. Last thing I need to fix is updating the task and entity status properly from the frontend. For better clarity over what has changed, I think this code from enums.py helps to illustrate it: class TaskEvent(StrEnum, Enum):
"""Task events via API.
`MAP` -- Set to *locked for mapping*, i.e. mapping in progress.
`FINISH` -- Set to *unlocked to validate*, i.e. is mapped.
`FINISH` -- Request recent task ready to be validate.
`GOOD` -- Set the state to *unlocked done*.
`BAD` -- Set the state *unlocked to map* again, to be mapped once again.
`SPLIT` -- Set the state *unlocked done* then generate additional
subdivided task areas.
`MERGE` -- Set the state *unlocked done* then generate additional
merged task area.
`ASSIGN` -- For a requester user to assign a task to another user.
Set the state *locked for mapping* passing in the required user id.
Also notify the user they should map the area.
`COMMENT` -- Keep the state the same, but simply add a comment.
"""
MAP = "MAP"
FINISH = "FINISH"
VALIDATE = "VALIDATE"
GOOD = "GOOD"
BAD = "BAD"
SPLIT = "SPLIT"
MERGE = "MERGE"
ASSIGN = "ASSIGN"
COMMENT = "COMMENT"
class MappingState(StrEnum, Enum):
"""State options for tasks in FMTM.
NOTE We no longer have states invalidated / bad, and instead rely on the
EntityState.MARKED_BAD buildings to display red on the map.
"""
UNLOCKED_TO_MAP = "UNLOCKED_TO_MAP"
LOCKED_FOR_MAPPING = "LOCKED_FOR_MAPPING"
UNLOCKED_TO_VALIDATE = "UNLOCKED_TO_VALIDATE"
LOCKED_FOR_VALIDATION = "LOCKED_FOR_VALIDATION"
UNLOCKED_DONE = "UNLOCKED_DONE"
class EntityState(IntEnum, Enum):
"""State options for Entities in ODK.
NOTE here we started with int enums and it's hard to migrate.
NOTE we will continue to use int values in the form.
NOTE we keep BAD=6 for legacy reasons too.
"""
READY = 0
OPEN_IN_ODK = 1
SURVEY_SUBMITTED = 2
MARKED_BAD = 6 So with these updates the whole idea is to post TaskEvent to the API, which creates an entry in the events table. The MappingStatus will be automatically set from that. We can also post the EntityState to update it, but I need to work on that part a bit more π |
Sure, I'll make a branch and continue. I'll look through it and make the frontend fixes. |
Fixed all the remaining issues. Going to merge this, but the Playwright tests are still a bit broken, so this can't deploy to dev. Could you take a look into the tests please @NSUWAL123 ? π |
What type of PR is this? (check all applicable)
Related Issue
Fixes #1610
Describe this PR
Redesign of how the task locking works:
This includes a pretty major migration to the task_history table, changing the fields and table name to task_events.
The indexes are also all rebuilt.
Also includes fixes to various endpoints and frontend usage of endpoints after refactor in #1834
Review Guide
Notes for the reviewer. How to test this change?
Checklist before requesting a review
[optional] What gif best describes this PR or how it makes you feel?