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

Added Candidate Detail endpoint to CandidateAPI #9614

Merged

Conversation

dcyoung-dev
Copy link
Contributor

Context

The GiT CRM team need a way of accessing data about a specific candidate rather than a list of candidates

Changes proposed in this pull request

Added new candidates/:candidate_id endpoint to each version of the Candidate API

Guidance to review

Link to Trello card

https://trello.com/c/ts3kEarX

Things to check

  • If the code removes any existing feature flags, a data migration has also been added to delete the entry from the database
  • This code does not rely on migrations in the same Pull Request
  • If this code includes a migration adding or changing columns, it also backfills existing records for consistency
  • If this code adds a column to the DB, decide whether it needs to be in analytics yml file or analytics blocklist
  • API release notes have been updated if necessary
  • If it adds a significant user-facing change, is it documented in the CHANGELOG?
  • Required environment variables have been updated added to the Azure KeyVault
  • Inform data insights team due to database changes

@dcyoung-dev dcyoung-dev added the deploy_v2 Deploy the review app to AKS label Jul 31, 2024
@dcyoung-dev dcyoung-dev requested a review from a team July 31, 2024 16:54
@dcyoung-dev dcyoung-dev self-assigned this Jul 31, 2024
@github-actions github-actions bot temporarily deployed to review_aks-9614 July 31, 2024 16:59 Destroyed
@github-actions github-actions bot temporarily deployed to review_aks-9614 July 31, 2024 17:15 Destroyed
@github-actions github-actions bot temporarily deployed to review_aks-9614 August 1, 2024 13:32 Destroyed
This endpoint follows the same data structure and query pattern as the index page.

API Documentation has also been updated, with this endpoint being added to all previous versions as a non-breaking change.
`#index_query` now takes the `updated_since` argument
Moved the controller query to the serializers. This keeps all the information together in the serializer
@dcyoung-dev dcyoung-dev force-pushed the dy-add-a-candidate-detail-endpoint-to-the-candidate-api branch from 4763738 to 6f5a155 Compare August 1, 2024 13:38
@dcyoung-dev dcyoung-dev marked this pull request as ready for review August 1, 2024 13:39
@github-actions github-actions bot temporarily deployed to review_aks-9614 August 1, 2024 13:44 Destroyed
@github-actions github-actions bot temporarily deployed to review_aks-9614 August 1, 2024 14:06 Destroyed
Comment on lines -3 to -28
class V13 < Base
def serialize(candidates)
super.map do |candidate|
candidate[:attributes][:application_forms].each do |form|
application_form = ApplicationForm.find(form[:id])
form.merge!(
application_choices: serialize_application_choices(application_form),
references: serialize_references(application_form),
qualifications: serialize_qualifications(application_form),
personal_statement: serialize_personal_statement(application_form),
)
end

candidate
end
end

def query
Candidate
.left_outer_joins(application_forms: { application_choices: %i[provider course interviews], application_references: [], application_qualifications: [] })
.includes(application_forms: { application_choices: %i[provider course course_option interviews], application_qualifications: [], application_references: [] })
.where('candidates.updated_at > :updated_since OR application_forms.updated_at > :updated_since OR application_choices.updated_at > :updated_since OR "references".updated_at > :updated_since OR application_qualifications.updated_at > :updated_since', updated_since:)
.where('application_forms.recruitment_cycle_year = ? OR candidates.created_at > ?', RecruitmentCycle.current_year, CycleTimetable.apply_deadline(RecruitmentCycle.previous_year))
.order(id: :asc)
.distinct
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was an exact copy of the V12 implementation

@github-actions github-actions bot temporarily deployed to review_aks-9614 August 1, 2024 14:23 Destroyed
@github-actions github-actions bot temporarily deployed to review_aks-9614 August 2, 2024 09:05 Destroyed
.where(application_forms: { recruitment_cycle_year: RecruitmentCycle.current_year })
.or(Candidate.where('candidates.created_at > ? ', CycleTimetable.apply_deadline(RecruitmentCycle.previous_year)))
.includes(application_forms: :application_choices)
.find(candidate_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

SELECT "candidates".*
FROM "candidates"
LEFT OUTER JOIN "application_forms" ON "application_forms"."candidate_id" = "candidates"."id"
WHERE ("application_forms"."recruitment_cycle_year" = 2024 
    OR "candidates".created_at > '2023-09-19 17:00:00')
  AND "candidates"."id" = 2452
LIMIT 1

Just posting the query to help my future me.

@dcyoung-dev dcyoung-dev merged commit 8dddcd1 into main Aug 2, 2024
23 checks passed
@dcyoung-dev dcyoung-dev deleted the dy-add-a-candidate-detail-endpoint-to-the-candidate-api branch August 2, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy_v2 Deploy the review app to AKS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants