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

Dds 1691 -- New API endpoint to extend the deadline: ProjectStatus.patch #1480

Merged
merged 49 commits into from
Oct 24, 2023

Conversation

rv0lt
Copy link
Member

@rv0lt rv0lt commented Oct 10, 2023

Read this before submitting the PR

  1. Always create a Draft PR first
  2. Go through sections 1-5 below, fill them in and check all the boxes
  3. Make sure that the branch is updated; if there's an "Update branch" button at the bottom of the PR, rebase or update branch.
  4. When all boxes are checked, information is filled in, and the branch is updated: mark as Ready For Review and tag reviewers (top right)
  5. Once there is a submitted review, implement the suggestions (if reasonable, otherwise discuss) and request an new review.

If there is a field which you are unsure about, enter the edit mode of this description or go to the PR template; There are invisible comments providing descriptions which may be of help.

1. Description / Summary

Implemented the functionality in the API of extend the deadline for a project with a new endpoint:

The new endpoint is PATCH /proj/status

Currently, it only supports the functionality of extending the deadline for which the following body is necessary:

{
"new_deadline_in": int
}

If, new_deadline_in has not been provided then, nothing is executed. If it is provided, it needs to be an integer that defines the extension in days for the new deadline. These days while be added on top of the current day's left.

The workflow process that should be handled when project status extend deadline is called is as follows:

  1. CLI: call ProjectStatus.patch
  2. API: ProjectStatus.patch returns project status and deadline (days left)
  3. CLI: Print project status, deadline, and chosen new deadline. Ask for confirmation.
  4. CLI: call ProjectStatus.patch with confirmed flag
  5. API: ProjectStatus.patch verifies correct status, and ok deadline, and extends the deadline.

2. Jira task / GitHub issue

Link to the github issue or add the Jira task ID here.

3. Type of change

What type of change(s) does the PR contain?

Check the relevant boxes below. For an explanation of the different sections, enter edit mode of this PR description template.

  • New feature
    • Breaking: Why / How? Add info here.
    • Non-breaking
  • Database change: Remember the to include a new migration version, or explain here why it's not needed.
  • Bug fix
  • Security Alert fix
  • Documentation
  • Workflow
  • Tests only

4. Additional information

5. Actions / Scans

Check the boxes when the specified checks have passed.

For information on what the different checks do and how to fix it if they're failing, enter edit mode of this description or go to the PR template.

  • Black
  • Prettier
  • Yamllint
  • Tests
  • CodeQL
  • Trivy
  • Snyk

@rv0lt rv0lt changed the title Dds 1691 new api endpoint project status.put Dds 1691 new api endpoint project status Oct 10, 2023
tests/api/test_project.py Fixed Show fixed Hide fixed
tests/api/test_project.py Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #1480 (494b7bc) into dev (e9a0d1d) will increase coverage by 0.12%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev    #1480      +/-   ##
==========================================
+ Coverage   90.19%   90.32%   +0.12%     
==========================================
  Files          29       29              
  Lines        4426     4484      +58     
==========================================
+ Hits         3992     4050      +58     
  Misses        434      434              
Files Coverage Δ
dds_web/api/project.py 91.39% <100.00%> (+1.07%) ⬆️

@rv0lt rv0lt marked this pull request as ready for review October 11, 2023 12:28
@rv0lt rv0lt self-assigned this Oct 12, 2023
@rv0lt rv0lt requested a review from a team October 12, 2023 14:58
Copy link
Member

@i-oden i-oden left a comment

Choose a reason for hiding this comment

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

Am I understanding it correctly if I say you're aiming at this being the full flow for the CLI and API?

  1. CLI: call ProjectStatus.get
  2. API: ProjectStatus.get returns project status and deadline
  3. CLI: Print project status, deadline, and chosen new deadline. Ask for confirmation.
  4. CLI: call ProjectStatus.patch
  5. API: ProjectStatus.patch verifies correct status, and ok deadline, and extends the deadline.

If so, also add this to the PR description so that it's easier to work on the CLI command part. If not add the correct imagined steps to the PR description 🙏🏻

dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
Copy link
Member

@i-oden i-oden left a comment

Choose a reason for hiding this comment

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

A few minor things

dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
rv0lt and others added 4 commits October 23, 2023 12:51
@rv0lt rv0lt requested a review from i-oden October 23, 2023 12:53
tests/api/test_project.py Show resolved Hide resolved
dds_web/api/project.py Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
Co-authored-by: Ina Odén Österbo <[email protected]>
Copy link
Member

@i-oden i-oden left a comment

Choose a reason for hiding this comment

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

Looking good, need some small adjustments though - e.g. change from days_in_expired to days_in_available and a change in an error message for the users

dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
dds_web/api/project.py Outdated Show resolved Hide resolved
rv0lt and others added 3 commits October 24, 2023 09:05
Co-authored-by: Ina Odén Österbo <[email protected]>
Co-authored-by: Ina Odén Österbo <[email protected]>
Co-authored-by: Ina Odén Österbo <[email protected]>
@i-oden i-oden changed the title Dds 1691 Added new API endpoint ProjectStatus.patch to extend the deadline Dds 1691 -- New API endpoint to extend the deadline: ProjectStatus.patch Oct 24, 2023
@i-oden
Copy link
Member

i-oden commented Oct 24, 2023

@rv0lt So since the new statuses added to the projectstatuses table have the exact same creation date and time, I'm wondering if there's a risk that the code thinks that the Expired status is added last and therefore the system thinks that that is the current status..? Maybe we should do for example

                    new_status_row = self.expire_project(
                        project=project,
                        current_time=curr_date - <1 second here>, 
                        deadline_in=project.responsible_unit.days_in_expired,
                    )

?

Or if we should add checks in the tests that you have added that verifies that project.current_status is Available.

Also, currently we set (example above) deadline_in = project.responsible_unit.days_in_expired but it feels like it could become confusing to us in the case that the deadline for the Expired status is after the deadline for the Available status that's added. So I'm wondering if we should set the deadline_in here as e.g. tomorrow.

@rv0lt
Copy link
Member Author

rv0lt commented Oct 24, 2023

@rv0lt So since the new statuses added to the projectstatuses table have the exact same creation date and time, I'm wondering if there's a risk that the code thinks that the Expired status is added last and therefore the system thinks that that is the current status..? Maybe we should do for example

                    new_status_row = self.expire_project(
                        project=project,
                        current_time=curr_date - <1 second here>, 
                        deadline_in=project.responsible_unit.days_in_expired,
                    )

?

Or if we should add checks in the tests that you have added that verifies that project.current_status is Available.

Also, currently we set (example above) deadline_in = project.responsible_unit.days_in_expired but it feels like it could become confusing to us in the case that the deadline for the Expired status is after the deadline for the Available status that's added. So I'm wondering if we should set the deadline_in here as e.g. tomorrow.

  1. The double-checking that the project is kept as available sounds alright. Maybe set again the curr date before the call of the expire and release so it has different seconds
  2. Yeah sounds reasonable that the deadilne here can be some dummy data to avoid confussion

@i-oden
Copy link
Member

i-oden commented Oct 24, 2023

@rv0lt So since the new statuses added to the projectstatuses table have the exact same creation date and time, I'm wondering if there's a risk that the code thinks that the Expired status is added last and therefore the system thinks that that is the current status..? Maybe we should do for example

                    new_status_row = self.expire_project(
                        project=project,
                        current_time=curr_date - <1 second here>, 
                        deadline_in=project.responsible_unit.days_in_expired,
                    )

?
Or if we should add checks in the tests that you have added that verifies that project.current_status is Available.
Also, currently we set (example above) deadline_in = project.responsible_unit.days_in_expired but it feels like it could become confusing to us in the case that the deadline for the Expired status is after the deadline for the Available status that's added. So I'm wondering if we should set the deadline_in here as e.g. tomorrow.

1. The double-checking that the project is kept as available sounds alright. Maybe set again the curr date before the call of the expire and release so it has different seconds

2. Yeah sounds reasonable that the deadilne here can be some dummy data to avoid confussion

Great. Do that.

  1. Expired should have one second before Available.
  2. Add check that the status is available still
  3. Change deadline_in=project.responsible_unit.days_in_expired to deadline_in=1

Copy link
Member

@i-oden i-oden left a comment

Choose a reason for hiding this comment

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

If the tests pass now, this PR is approved and you can merge!

@rv0lt rv0lt merged commit de6e3fb into dev Oct 24, 2023
14 checks passed
@rv0lt rv0lt deleted the DDS-1691-New-API-endpoint-ProjectStatus.put branch October 24, 2023 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants