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

MattT/APPEALS-43725: Extract notify_appellant Call from QuaterlyNotificationsJob to Decrease Runtime #21643

Merged
merged 31 commits into from
May 16, 2024

Conversation

ThorntonMatthew
Copy link
Contributor

@ThorntonMatthew ThorntonMatthew commented May 15, 2024

Resolves APPEALS-43725

Description

These changes extract synchronous, often slow (due to the need for external service calls), operations from happening within the QuarterlyNotificationsJob and into its own NotificationInitializationJob. This is to allow the quarterly job to run MUCH faster.

Additionally, functionality was added to CaseflowJob to allow for batch enqueueing of messages/jobs.

Acceptance Criteria

  • Create a new NotificationInitializationJob (you can name it something else if you'd like)
    • This job will be responsible for:
      • Accepting the following parameters:
        • An appeal object (required)
        • A template_name string (required)
        • An appeal_status string (optional - only required if template_name is "Quarterly Notification")
      • The job will ensure appeal_status is valid if template_name is "Quarterly Notification"
      • The params passed into the job will be provided to AppellantNotification.notify_appellant
      • The job has error handling put in place where errors are rescued and logged to STDERR and Sentry.
  • Replace any calls to AppellantNotification.notify_appellant in QuarterlyNotificationsJob with a .peform_later call on the new job class.
  • The QuarterlyNotificationsJob's runtime duration in ProdTest/Production absolutely must not come anywhere close to exceeding five hours in length.
    • Be prepared to benchmark the before/after effects of this optimization.

Testing Plan

  1. Go to Jira Issue/Test Plan Link or list them below
  • For feature branches merging into master: Was this deployed to UAT?

Backend

Integrations: Adding endpoints for external APIs

  • Check that Caseflow's external API code for the endpoint matches the code in the relevant integration repo
    • Request: Service name, method name, input field names
    • Response: Check expected data structure
    • Check that calls are wrapped in MetricService record block
  • Check that all configuration is coming from ENV variables
    • Listed all new ENV variables in description
    • Worked with or notified System Team that new ENV variables need to be set
  • Update Fakes
  • For feature branches: Was this tested in Caseflow UAT

Best practices

Code Documentation Updates

  • Add or update code comments at the top of the class, module, and/or component.

Tests

Test Coverage

Did you include any test coverage for your code? Check below:

  • RSpec
  • Jest
  • Other

Code Climate

Your code does not add any new code climate offenses? If so why?

  • No new code climate issues added

Monitoring, Logging, Auditing, Error, and Exception Handling Checklist

Monitoring

  • Are performance metrics (e.g., response time, throughput) being tracked?
  • Are key application components monitored (e.g., database, cache, queues)?
  • Is there a system in place for setting up alerts based on performance thresholds?

Logging

  • Are logs being produced at appropriate log levels (debug, info, warn, error, fatal)?
  • Are logs structured (e.g., using log tags) for easier querying and analysis?
  • Are sensitive data (e.g., passwords, tokens) redacted or omitted from logs?
  • Is log retention and rotation configured correctly?
  • Are logs being forwarded to a centralized logging system if needed?

Auditing

  • Are user actions being logged for audit purposes?
  • Are changes to critical data being tracked ?
  • Are logs being securely stored and protected from tampering or exposing protected data?

Error Handling

  • Are errors being caught and handled gracefully?
  • Are appropriate error messages being displayed to users?
  • Are critical errors being reported to an error tracking system (e.g., Sentry, ELK)?
  • Are unhandled exceptions being caught at the application level ?

Exception Handling

  • Are custom exceptions defined and used where appropriate?
  • Is exception handling consistent throughout the codebase?
  • Are exceptions logged with relevant context and stack trace information?
  • Are exceptions being grouped and categorized for easier analysis and resolution?

@@ -128,9 +128,6 @@
# One time Appeal States migration for Legacy & AMA Appeal Batch Sizes
ENV["STATE_MIGRATION_JOB_BATCH_SIZE"] ||= "1000"

# Quarterly Notifications Batch Sizes
ENV["QUARTERLY_NOTIFICATIONS_JOB_BATCH_SIZE"] ||= "1000"
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 environmental variable is no longer required due to the refactoring the QuarterlyNotificationsJob has undergone.

@ThorntonMatthew ThorntonMatthew changed the title MattT/APPEALS-43725: MattT/APPEALS-43725: Extract notify_appellant Call from QuaterlyNotificationsJob to Decrease Runtime MattT/APPEALS-43725: Extract notify_appellant Call from QuaterlyNotificationsJob to Decrease Runtime May 15, 2024
@ThorntonMatthew ThorntonMatthew changed the base branch from feature/APPEALS-43597 to master May 15, 2024 16:53
Copy link

codeclimate bot commented May 15, 2024

Code Climate has analyzed commit 9531b58 and detected 6 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 6

View more on Code Climate.

@ThorntonMatthew ThorntonMatthew marked this pull request as ready for review May 15, 2024 19:17
@ThorntonMatthew ThorntonMatthew changed the base branch from master to feature/APPEALS-43597 May 16, 2024 17:04
@ThorntonMatthew ThorntonMatthew merged commit eb71686 into feature/APPEALS-43597 May 16, 2024
15 of 16 checks passed
@ThorntonMatthew ThorntonMatthew deleted the MattT/APPEALS-43725 branch May 16, 2024 17:04
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

1 participant