Skip to content

Commit

Permalink
Mg 948 consistent results (#70)
Browse files Browse the repository at this point in the history
* Split CbvFlowsController into multiple controllers

Multiple controllers will be easier to test, reason about, and
simultaneously edit as we continue development. This commit splits up
the controllers as such:

* All CBV flow pages still have URLs under `/cbv/`
* The controllers are nested in the `app/controllers/cbv` directory, and
  are within a new `Cbv` Ruby module accordingly. E.g. `/cbv/entry` is
  in `app/controllers/cbv/entries_controller.rb` and the class name is
  `Cbv::EntriesController`.
* Common functionality is extracted into a `Cbv::BaseController` which
  all pages inherit from.

This refactor also changes a couple other things:
1. The invitation URL is now not in the `/cbv/` URL path. It is now
   `/invitations/new?secret=[secret]`. I've added a redirect.
2. Moves I18n keys to relative keys where possible

[Finishes FFS-807](https://jiraent.cms.gov/browse/FFS-807)

* Subscribe to ninety_days_synced

* Wait for ninety days synced

* Filter by the previous 90 days

---------

Co-authored-by: Tom Dooner <[email protected]>
  • Loading branch information
allthesignals and tdooner authored Jun 24, 2024
1 parent 4dc900d commit 6e7e103
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 62 deletions.
2 changes: 1 addition & 1 deletion app/app/controllers/cbv/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def fetch_payroll
end_user_account_ids = pinwheel.fetch_accounts(end_user_id: @cbv_flow.pinwheel_end_user_id)["data"].map { |account| account["id"] }

end_user_account_ids.map do |account_id|
pinwheel.fetch_paystubs(account_id: account_id)["data"]
pinwheel.fetch_paystubs(account_id: account_id, from_pay_date: 90.days.ago.strftime("%Y-%m-%d"))["data"]
end.flatten
end
end
2 changes: 1 addition & 1 deletion app/app/controllers/webhooks/pinwheel/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create
return render json: { error: "Invalid signature" }, status: :unauthorized
end

if params["event"] == "paystubs.added"
if params["event"] == "paystubs.ninety_days_synced"
@cbv_flow = CbvFlow.find_by_pinwheel_end_user_id(params["payload"]["end_user_id"])

if @cbv_flow
Expand Down
2 changes: 1 addition & 1 deletion app/app/javascript/controllers/cbv/employer_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class extends Controller {
console.log("Disconnected");
},
received: (data) => {
if (data.event === 'paystubs.added') {
if (data.event === 'paystubs.ninety_days_synced') {
this.formTarget.submit();
}
}
Expand Down
56 changes: 0 additions & 56 deletions app/app/javascript/controllers/cbv_flows_controller.js

This file was deleted.

4 changes: 2 additions & 2 deletions app/app/services/pinwheel_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def fetch_accounts(end_user_id:)
@http.get(build_url("#{END_USERS}/#{end_user_id}/accounts")).body
end

def fetch_paystubs(account_id:)
@http.get(build_url("#{ACCOUNTS_ENDPOINT}/#{account_id}/paystubs")).body
def fetch_paystubs(account_id:, **params)
@http.get(build_url("#{ACCOUNTS_ENDPOINT}/#{account_id}/paystubs"), params).body
end

def create_link_token(end_user_id:, response_type:, id:)
Expand Down
3 changes: 2 additions & 1 deletion app/app/services/pinwheel_webhook_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def create_subscription(tunnel_url, name)
puts " Registering Pinwheel webhooks for Ngrok tunnel..."
response = @pinwheel.create_webhook_subscription([
"account.added",
"paystubs.added"
"paystubs.added",
"paystubs.ninety_days_synced"
], URI.join(tunnel_url, "/webhooks/pinwheel/events", format_identifier_hash(name)))
new_webhook_subscription_id = response["data"]["id"]
puts " ✅ Set up Pinwheel webhook: #{new_webhook_subscription_id}"
Expand Down

0 comments on commit 6e7e103

Please sign in to comment.