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

[CST-1368] Change ECTs induction start date and cohort when DQT record updated #3265

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

lazydevorg
Copy link
Contributor

@lazydevorg lazydevorg commented Apr 17, 2023

Context

Changes proposed in this pull request

  • Service Participants::SyncDqtInductionStartDate added and called from Participants::ParticipantValidationForm
  • Model SyncDqtInductionStartDateError used to take track of participant who can't be processed. The error messages are saved in the DB for each participant.

@github-actions
Copy link

Created review app at https://ecf-review-pr-3265.london.cloudapps.digital

@github-actions
Copy link

Smoke tests passed against the review app.

@lazydevorg lazydevorg closed this Apr 18, 2023
@lazydevorg lazydevorg reopened this Apr 18, 2023
@lazydevorg lazydevorg closed this Apr 19, 2023
@lazydevorg lazydevorg reopened this Apr 19, 2023
@lazydevorg lazydevorg changed the title Cst 1368 change ects cohort when dqt updated 2 [CST-1368] Change ECTs induction start date and cohort when DQT record updated Apr 25, 2023
@lazydevorg lazydevorg closed this Apr 25, 2023
@lazydevorg lazydevorg reopened this Apr 25, 2023
@lazydevorg lazydevorg marked this pull request as ready for review April 25, 2023 11:52
def call
return false unless FeatureFlag.active?(:cohortless_dashboard)
return false if @dqt_induction_start_date.nil?
return false if @participant_profile.induction_start_date.present?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still should go ahead even when the participant has already an induction_start_date instead of returning false.

The reason is that some of their induction records might still be in the wrong cohort and need to be amended.

dqt_cohort = Cohort.containing_date(@dqt_induction_start_date)
return false if dqt_cohort.nil?

if dqt_cohort == participant_cohort
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. We should still call amend_cohort in this situation because even if the latest induction record is in the right cohort, some of the old induction records might still be in the wrong cohort and need to get it amended.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we do this and, as per your comment above, then this job will run all the time for each participant.
I think the ask was to do it just for the participants who did not have the induction start date set.
I'll double check whether this is still the case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, exactly, because:

  • we already have participants with wrong cohorts in their historical induction records and this is the tool to fix them, no matter their existing induction start date.
  • their existing induction date might not match the one in their DQT record and better to have the right one coming from DQT.
  • we want to run this tool for ALL participants only one time to update their induction start date

Copy link
Contributor

@ltello ltello Apr 26, 2023

Choose a reason for hiding this comment

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

Once this one-off task is done, then your tool will only run for each new participant, for re-validations in support and the periodic job programmed for participants with no QTS

current_induction_record = @participant_profile.induction_records.latest
participant_cohort = current_induction_record.cohort
dqt_cohort = Cohort.containing_date(@dqt_induction_start_date)
return false if dqt_cohort.nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that in this case we should also save an error for the participant to track that the target cohort for this participant has not been setup yet in our service.

This might help to warn us that we need to setup missing cohorts.


def save_error_message(amend_cohort)
error = SyncDqtInductionStartDateError.find_or_create_by(participant_profile: @participant_profile) # rubocop:disable Rails/SaveBang
error.error_message = amend_cohort.errors.full_messages.join(", ")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, see my comment below about each error recorded in its own entry.

@ltello ltello force-pushed the CST-1368-change-ects-cohort-when-dqt-updated-2 branch 5 times, most recently from b1e6af7 to 04c872b Compare April 27, 2023 13:28
@peteryates
Copy link
Member

@lazydevorg - this looks good to me, will approve once the conflict is resolved 👌🏽

@ltello ltello force-pushed the CST-1368-change-ects-cohort-when-dqt-updated-2 branch 2 times, most recently from b6f0246 to 55d7d0a Compare May 2, 2023 20:19
@ltello ltello force-pushed the CST-1368-change-ects-cohort-when-dqt-updated-2 branch from 55d7d0a to 55a4be4 Compare May 2, 2023 20:22
@ltello ltello mentioned this pull request May 3, 2023
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.

None yet

3 participants