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

[CPDLP-3228] NPQ MVP Prep - Disable NPQ endpoints in ECF specific separation environment #5027

Conversation

mooktakim
Copy link
Contributor

@mooktakim mooktakim commented Jul 10, 2024

Context

Changes proposed in this pull request

  • disable_npq_endpoints feature added
  • NpqApiEndpointRoute created to constraint NPQ routes
  • For NPQ & ECF shared declarations routes:
    • Declarations create action returns error if course_identifier includes npq course
    • ParticipantDeclarations::Index updated to not return NPQ declarations if feature enabled
    • Api::V3::ParticipantDeclarationsQuery updated to not return NPQ declarations if feature enabled

Guidance to review

@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from df70c3f to bda6e60 Compare July 10, 2024 11:10
Copy link

Review app deployed to https://cpd-ecf-review-5027-web.test.teacherservices.cloud

@mooktakim mooktakim requested a review from a team July 10, 2024 12:20
Copy link
Collaborator

@cwrw cwrw left a comment

Choose a reason for hiding this comment

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

could we also disable NPQ statements as well from the statements joint endpoint?

service = RecordDeclaration.new({ cpd_lead_provider: }.merge(permitted_params["attributes"] || {}))
attributes = permitted_params["attributes"] || {}

if FeatureFlag.active?(:disable_npq_endpoints) && attributes[:course_identifier].to_s.starts_with?("npq-")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand why we might have this at the controller level, is there an argument of having this check at the record service level instead 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we can identify the NPQ declarations, I think it's best to return as soon as possible; that way, we don't interfere with the service classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The feature check is now done in RecordDeclaration service class

config/routes.rb Outdated Show resolved Hide resolved
config/routes.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@leandroalemao leandroalemao left a comment

Choose a reason for hiding this comment

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

Hi @mooktakim
Think /api/v{1}{2}{3}/participant-declarations/{id}/void is a shared endpoint as well as the statements one like @cwrw said?
As an idea, maybe we could return a deprecation warning do LPs rather than a 404 error?

@cwrw
Copy link
Collaborator

cwrw commented Jul 11, 2024

As an idea, maybe we could return a deprecation warning do LPs rather than a 404 error?

@leandroalemao Good question, LPs asked for a "sandbox" like environment without the NPQ endpoints, so we have to disable them, also this will probably be used when we switch off the service so we need to completely disable those

@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from bda6e60 to 1f6b485 Compare July 11, 2024 13:53
@mooktakim mooktakim requested review from leandroalemao and cwrw July 11, 2024 14:09
@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from 1f6b485 to 4bc13c6 Compare July 12, 2024 13:09
@mooktakim
Copy link
Contributor Author

Hi @mooktakim Think /api/v{1}{2}{3}/participant-declarations/{id}/void is a shared endpoint as well as the statements one like @cwrw said? As an idea, maybe we could return a deprecation warning do LPs rather than a 404 error?

@leandroalemao added void endpoints now too


class NpqApiEndpointRoute
def self.matches?(_request)
!FeatureFlag.active?(:disable_npq_endpoints)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should change this to check the ENV is separation instead and switch it to the feature flag later to avoid hitting the db everytime those URLs are hit? let's discuss

@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from 1dc4034 to 7fb238f Compare July 15, 2024 10:07
@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from 765078d to b2435b7 Compare July 15, 2024 15:54
@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from a624d14 to 9eb7a51 Compare July 15, 2024 16:22
@mooktakim mooktakim requested a review from cwrw July 15, 2024 16:36
Copy link
Contributor

@leandroalemao leandroalemao 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.. thanks @mooktakim 👍 😄

@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from 9eb7a51 to a2f4991 Compare July 17, 2024 08:41
@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from a2f4991 to fda99b8 Compare July 17, 2024 15:54
@@ -23,6 +23,10 @@ def statements
cohort_id: cohorts.map(&:id),
)

if NpqApiEndpoint.disable_npq_endpoints?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we can use statement_class and only return Finance::Statement::ECF there instead to avoid the extra queries here might be simpler, similar to the declaration query?

@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from 44dcc9c to da1fdea Compare July 17, 2024 18:17
Copy link
Collaborator

@cwrw cwrw left a comment

Choose a reason for hiding this comment

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

thank you @mooktakim ! Looks great, after this is tested we will need to wait for the separation env to be ready then we can switch the config to that from review and merge 🙌

@mooktakim mooktakim added the blocked-merge Do not merge this PR label Jul 18, 2024
@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from da1fdea to bb30096 Compare July 23, 2024 13:38
@@ -8,4 +8,9 @@

# Used to handle HTTP_X_WITH_SERVER_DATE header for server side datetime overwrite
config.middleware.use TimeTraveler

# Enable/disable aspects of the separation environment
Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry could this move to separation instead of migration env? :D

@mooktakim mooktakim force-pushed the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch from bb30096 to f8e2ce8 Compare July 24, 2024 09:04
@mooktakim mooktakim added this pull request to the merge queue Jul 24, 2024
Merged via the queue into main with commit 0a14dd2 Jul 24, 2024
31 checks passed
@mooktakim mooktakim deleted the 3228-npq-mvp-prep-disable-npq-endpoints-in-ecf-specific-separation-environment branch July 24, 2024 14:04
@mooktakim mooktakim removed the blocked-merge Do not merge this PR label Jul 24, 2024
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.

3 participants