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

BE | Ask va api Fix Inquiry bug and create FacilitiesDataJob #19976

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

Khoa-V-Nguyen
Copy link
Contributor

Summary

This Pull Request introduces several key updates aimed at improving the efficiency, accuracy, and functionality of our application. The highlights include enhanced search filtering, automated caching of facilities data, bug fixes, and updates to mock and static data files.


🔍 Changes

1. Update HealthFacilities#search

  • Enhancement: The search method now filters and only returns PATSR-approved facilities.
  • Impact: Ensures only valid, approved facilities are returned, enhancing data integrity and improving the user experience.

2. Create FacilitiesDataJob

  • New Job: Added a background job (FacilitiesDataJob) to cache facilities data every 24 hours.
  • Impact: Reduces API calls and improves system performance by ensuring that cached data is regularly updated.

3. Bug Fix: InquiryDetails Handling

  • Issue: Inquiry details were not correctly handling "it's a general question" responses.
  • Fix: Updated InquiryDetails to properly manage this scenario.
  • Impact: Resolves a user-facing bug and ensures better handling of general inquiries.

4. Update Mock & Static Data

  • File Added: get_facilities_mock_data.json
    • Purpose: Contains a list of PATSR-approved health facilities for testing and development purposes.
  • File Updated: static_data.json
    • Change: Updated to reflect the most recent additions from the CRM API.
    • Impact: Ensures that static data stays in sync with the CRM, improving data consistency across environments.

📚 Notes for Reviewers

  • Focus on the HealthFacilities#search logic to ensure edge cases are handled correctly.
  • Review the cron scheduling for FacilitiesDataJob to confirm the 24-hour interval meets system requirements.
  • Double-check the updates to mock and static data files for completeness and correctness.

🙏 Thank You

Thank you for reviewing this PR. Please provide any feedback or suggestions to further improve the functionality, performance, or maintainability of these changes.

Related issue(s)

Testing done

  • Search Filter: Verified that only PATSR-approved facilities are returned.
  • Background Job: Confirmed FacilitiesDataJob successfully caches data every 24 hours.
  • Bug Fix: Validated that "it's a general question" is handled properly in InquiryDetails.
  • Data Consistency: Verified that static_data.json and get_facilities_mock_data.json are up-to-date with CRM API data.

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected

Copy link

1 Warning
⚠️ This PR changes 239 LoC (not counting whitespace/newlines).

In order to ensure each PR receives the proper attention it deserves, we recommend not exceeding
200. Expect some delays getting reviews.

File Summary

Files

  • lib/periodic_jobs.rb (+1/-0)

  • modules/ask_va_api/app/controllers/ask_va_api/v0/health_facilities_controller.rb (+15/-1)

  • modules/ask_va_api/app/lib/ask_va_api/inquiries/payload_builder/inquiry_details.rb (+2/-1)

  • modules/ask_va_api/app/lib/ask_va_api/inquiries/payload_builder/shared_helpers.rb (+1/-1)

  • modules/ask_va_api/app/sidekiq/crm/facilities_data_job.rb (+20/-0)

  • modules/ask_va_api/spec/app/lib/ask_va_api/inquiries/payload_builder/submitter_profile_spec.rb (+1/-1)

  • modules/ask_va_api/spec/requests/ask_va_api/v0/health_facilities_spec.rb (+12/-106)

  • modules/ask_va_api/spec/requests/ask_va_api/v0/static_data_spec.rb (+1/-1)

  • modules/ask_va_api/spec/sidekiq/crm/facilities_data_job_spec.rb (+45/-0)

  • modules/ask_va_api/spec/support/shared_contexts.rb (+15/-15)

    Note: We exclude files matching the following when considering PR size:

    *.csv, *.json, *.tsv, *.txt, *.md, Gemfile.lock, app/swagger, modules/mobile/docs, spec/fixtures/, spec/support/vcr_cassettes/, modules/mobile/spec/support/vcr_cassettes/, db/seeds, modules/vaos/app/docs, modules/meb_api/app/docs, modules/appeals_api/app/swagger/, *.bru, *.pdf
    

Big PRs are difficult to review, often become stale, and cause delays.

Generated by 🚫 Danger

Copy link
Contributor

@hemeshvpatel hemeshvpatel left a comment

Choose a reason for hiding this comment

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

Lgtm

@Khoa-V-Nguyen Khoa-V-Nguyen force-pushed the ask-va-api-update-static-data-file branch from a36579c to 604225b Compare December 20, 2024 17:03
ryan-mcneil
ryan-mcneil previously approved these changes Dec 20, 2024
- get_facilties_mock_data.json is a list of PATSR approved health facilities
- static_data.json is now up to data with the most recent addition from CRM API
- inquiry_details now handles `it's a general question` correctly
- Job will run every 24hours to cache the data
- search now will filter and allow only patsr approved facilities
@Khoa-V-Nguyen Khoa-V-Nguyen force-pushed the ask-va-api-update-static-data-file branch from 604225b to 8d46fd8 Compare December 20, 2024 18:29
Copy link
Contributor

@ryan-mcneil ryan-mcneil left a comment

Choose a reason for hiding this comment

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

that's better 👌

@Khoa-V-Nguyen Khoa-V-Nguyen merged commit 69d29cc into master Dec 20, 2024
25 checks passed
@Khoa-V-Nguyen Khoa-V-Nguyen deleted the ask-va-api-update-static-data-file branch December 20, 2024 18:41
ojbucao pushed a commit that referenced this pull request Dec 20, 2024
* Created get_facilities_mock_data.json and update static_data.json

- get_facilties_mock_data.json is a list of PATSR approved health facilities
- static_data.json is now up to data with the most recent addition from CRM API

* Fix bug in InquiryDetails and update spec

- inquiry_details now handles `it's a general question` correctly

* Created FacilitiesDataJob

- Job will run every 24hours to cache the data

* Update HealthFacilities#search

- search now will filter and allow only patsr approved facilities
derekhouck pushed a commit that referenced this pull request Dec 31, 2024
* Created get_facilities_mock_data.json and update static_data.json

- get_facilties_mock_data.json is a list of PATSR approved health facilities
- static_data.json is now up to data with the most recent addition from CRM API

* Fix bug in InquiryDetails and update spec

- inquiry_details now handles `it's a general question` correctly

* Created FacilitiesDataJob

- Job will run every 24hours to cache the data

* Update HealthFacilities#search

- search now will filter and allow only patsr approved facilities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants