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

POLIO-1770, POLIO-1768: delete unused scopes + migration #1837

Conversation

quang-le
Copy link
Member

What problem is this PR solving? Explain here in one sentence.

Related JIRA tickets : POLIO-1770, POLIO-1768

Self proofreading checklist

  • Did I use eslint and black formatters
  • Is my code clear enough and well documented
  • Are my typescript files well typed
  • New translations have been added or updated if new strings have been introduced in the frontend
  • My migrations file are included
  • Are there enough tests
  • Documentation has been included (for new feature)

Doc

N/A

Changes

  • POLIO-1768: migration

    • Add migration that deletes unused scopes
    • Note: rounds w/o campaign were not deleted
  • POLIO-1770: update API

    • Check existing scopes:
      • if campaign switches to round scope, delete campaign scope and vice-versa
      • if scope per campaign, ignore scopes per round received from front end and vice versa
      • Add tests

How to test

On polio DB:

  • Go to campaigns
  • Open a campaign
  • Go to Scopes tab
  • Tick "separate scopes per round" box
  • Add new scope
  • Save

--> The old scopes should have been removed from GET response, but will still be visible in front-end because of formik state. Reloading the page will make it diappear

  • Repeat the operation the other way around

Print screen / video

Uploading Screen Recording 2024-11-29 at 15.13.32.mov…

Notes

MERGES INTO #1830

Follow the Conventional Commits specification

The merge message of a pull request must follow the Conventional Commits specification.

This convention helps to automatically generate release notes.

Use lowercase for consistency.

Example:

fix: empty instance pop up

Refs: IA-3665

Note that the Jira reference is preceded by a line break.

Both the line break and the Jira reference are entered in the Add an optional extended description… field.

- if separate scopes per round: delete campaign scope
- else: delete round scopes
- delete unused scopes when switching scope type
- only loop through used scope when updating
Copy link
Member

@kemar kemar left a comment

Choose a reason for hiding this comment

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

LGTM

The logic seems good and kudos for the test which helps to understand the code.

I suggest some simplifications to make the code easier to read. You're free to apply them or not.

plugins/polio/migrations/0206_delete_unused_scopes.py Outdated Show resolved Hide resolved
plugins/polio/migrations/0206_delete_unused_scopes.py Outdated Show resolved Hide resolved
plugins/polio/api/campaigns/campaigns.py Outdated Show resolved Hide resolved
@quang-le quang-le merged commit af7b7fe into POLIO-1753_split_pdf_data_per_vaccine_per_round Dec 2, 2024
3 checks passed
@quang-le quang-le deleted the POLIO-1770_delete_unused_scopes branch December 2, 2024 10:17
@butofleury butofleury added the user tested Has already been tested on staging label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released user tested Has already been tested on staging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants