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

[API] Visit patch request to start next stage #7479

Merged
merged 8 commits into from
Oct 27, 2021

Conversation

laemtl
Copy link
Contributor

@laemtl laemtl commented Jun 14, 2021

Patch request url: /candidates/CandID/Visit
Patch request format:

{
    "CandID"  : 317604,
    "Visit"   : 'Visit 01',
    "Site"    : 'DCC',
    "Battery" : 'Stale',
    "Project" : 'Pumpernickel',
    "Stages" : {
        "Visit" : {
            "Date" : "YYYY-MM-DD",
            "Status" : "In Progress"
        }
    }
}

This will only 'start next stage' when 1. the payload contains a "Visit" stage with "In Progress" as Status 2. The current status of the Visit stage is "Not Started".

@laemtl laemtl requested a review from xlecours June 14, 2021 18:59
@laemtl laemtl force-pushed the 2021-06-14-api-next-stage branch from 71f9e63 to 9291868 Compare June 14, 2021 19:36
@laemtl laemtl requested a review from driusan June 14, 2021 19:36
@laemtl laemtl force-pushed the 2021-06-14-api-next-stage branch 2 times, most recently from b96a53b to bf6caa1 Compare June 14, 2021 19:42
Copy link
Contributor

@xlecours xlecours left a comment

Choose a reason for hiding this comment

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

I think we should find a solution that will allow to go from "Not started" to"In Progress" and also from "In Progress" to "Pass" or any other valid status. The get request returns a "Stages" with a property fro each stages.

"Stages": {
    "Screening": {
      "Date": "string",
      "Status": "Pass"
    }
  }

I think that a PATCH request with a similar object in the body could handle more types of transitions. Also, the frontend ask if scans were acquired, maybe we should add that.

modules/api/php/endpoints/candidate/visit/visit.class.inc Outdated Show resolved Hide resolved
modules/api/php/endpoints/candidate/visit/visit.class.inc Outdated Show resolved Hide resolved
@laemtl laemtl force-pushed the 2021-06-14-api-next-stage branch 3 times, most recently from 339dc1a to 98c77ce Compare June 15, 2021 03:58
@laemtl laemtl added the Area: API PR or issue related to the API label Jun 15, 2021
@laemtl laemtl force-pushed the 2021-06-14-api-next-stage branch from 98c77ce to 8828f69 Compare June 15, 2021 04:57
@laemtl laemtl force-pushed the 2021-06-14-api-next-stage branch from 8828f69 to a0766f2 Compare June 15, 2021 05:11
@laemtl
Copy link
Contributor Author

laemtl commented Jun 15, 2021

@xlecours My intuition is that implementing a solution to switch from In Progress to Pass implies some checks that I'm not familiar with. It's probably the same for Withdrawal and maybe Failure. This PR covers the functionality I need for a particular project, I may not have time to address your suggestion before a while.

@driusan
Copy link
Collaborator

driusan commented Jun 15, 2021

I agree with Xavier that it would be better to infer it from the same structure based on what stages are set in

    "Stages" : {
              "Screening" :  {
                  "Date" : "YYYY-MM-DD",
                  "Status" : "Pass|Failure|Withdrawal|In Progress"
              },
              "Visit" : {
                  "Date" : "YYYY-MM-DD",
                  "Status" : "Pass|Failure|Withdrawal|In Progress"
              },
              "Approval" : {
                  "Date" : "YYYY-MM-DD",
                  "Status" : "Pass|Failure|Withdrawal|In Progress"
              }

For the sake of starting a next stage, handling a PATCH request that sets the Status of Visit to In Progress is all that's really needed to handle starting a visit stage. The rest of the transitions can either return a "Not Implemented" or "Bad Request" result as appropriate.

@laemtl
Copy link
Contributor Author

laemtl commented Jun 15, 2021

@driusan Leaving some cases Not Implemented is a really good idea to address Xavier's suggestion in a limited time frame. I will do that shortly.

@xlecours
Copy link
Contributor

I have a bad feeling about using inheritance to solve the versioning problem. I understand that both endpoints are sharing code but, when we will move 0.0.4 from dev to prod, everything that is not in the subclass will need to be merge anyway.
@laemtl @driusan ?

Copy link
Contributor

@xlecours xlecours left a comment

Choose a reason for hiding this comment

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

This should also modify modules/api/static/schema.yml. I can push a contribution if you would like me to.

@laemtl
Copy link
Contributor Author

laemtl commented Jun 16, 2021

This should also modify modules/api/static/schema.yml. I can push a contribution if you would like me to.

I am not modifying v0.0.3 so do we need to change anything?

@xlecours
Copy link
Contributor

This should also modify modules/api/static/schema.yml. I can push a contribution if you would like me to.

I am not modifying v0.0.3 so do we need to change anything?

You are right. Let's add a new file then.

@laemtl laemtl added the State: Needs work PR awaiting additional work by the author to proceed label Aug 17, 2021
@laemtl laemtl removed the State: Needs work PR awaiting additional work by the author to proceed label Aug 24, 2021
@laemtl laemtl force-pushed the 2021-06-14-api-next-stage branch 2 times, most recently from 371e993 to 6fefe62 Compare August 24, 2021 21:44
@laemtl laemtl requested a review from xlecours August 24, 2021 21:44
@laemtl
Copy link
Contributor Author

laemtl commented Aug 24, 2021

@driusan @xlecours Comments addressed.

@driusan driusan added the Critical to release PR or issue is key for the release to which it has been assigned label Sep 14, 2021
@ridz1208 ridz1208 self-assigned this Sep 15, 2021
@laemtl laemtl added the State: Needs work PR awaiting additional work by the author to proceed label Sep 20, 2021
@laemtl laemtl force-pushed the 2021-06-14-api-next-stage branch from 118bfbe to f710b17 Compare September 28, 2021 17:25
@laemtl laemtl removed the State: Needs work PR awaiting additional work by the author to proceed label Sep 28, 2021
@laemtl laemtl requested a review from xlecours September 28, 2021 17:26
@laemtl
Copy link
Contributor Author

laemtl commented Sep 28, 2021

@driusan @xlecours Ready for re-review.

```
will update the stages date and status.

At this moment, we only support requests for the Visit stage with the In progress status,
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not clear to me what this means for the other fields. Should they be left out of the request? Included with garbage data?

Copy link
Contributor Author

@laemtl laemtl Sep 29, 2021

Choose a reason for hiding this comment

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

I removed Approval and Screening from the request.

@laemtl laemtl requested a review from driusan September 29, 2021 20:02
@christinerogers christinerogers dismissed xlecours’s stale review October 5, 2021 15:23

Re-review requested a week ago.

modules/api/static/schema-v0.0.4-dev.yml Outdated Show resolved Hide resolved
Co-authored-by: Xavier Lecours <xavier.lecours@mcin.ca>
@laemtl laemtl requested a review from xlecours October 5, 2021 19:02
Copy link
Contributor

@xlecours xlecours left a comment

Choose a reason for hiding this comment

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

I have tested it. It works all right. It's just that an empty array as a response is not ideal. I will approve this in its current state but it should return and empty response with a 204 status code.

modules/api/static/schema-v0.0.4-dev.yml Outdated Show resolved Hide resolved
modules/api/static/schema-v0.0.4-dev.yml Outdated Show resolved Hide resolved
modules/api/static/schema-v0.0.4-dev.yml Outdated Show resolved Hide resolved
@cmadjar cmadjar assigned xlecours and laemtl and unassigned xlecours Oct 19, 2021
@xlecours
Copy link
Contributor

laemtl#34 sent

@xlecours xlecours dismissed their stale review October 22, 2021 13:38

I contributed to this PR

removing checks and handling of other stages

Adding a NoContent response
@ridz1208
Copy link
Collaborator

@xlecours @driusan does this need change to the MD API documentation ?

@xlecours
Copy link
Contributor

@xlecours @driusan does this need change to the MD API documentation ?

yes. and it's already there.

@driusan driusan merged commit 58cddfc into aces:main Oct 27, 2021
@ridz1208 ridz1208 added this to the 24.0.0 milestone Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: API PR or issue related to the API Critical to release PR or issue is key for the release to which it has been assigned
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants