Skip to content

Commit

Permalink
Fix PinwheelService to hide unsupported employers from search
Browse files Browse the repository at this point in the history
When searching, we attempt to restrict search results to only those with
"paystubs" listed as a "job" that Pinwheel can perform for us. If
Pinwheel doesn't support the "paystubs" job, we can't get the data we
need for the product to actually work.

Some employers were breaking when clicking the "Select" button: these
employers didn't support the Pinwheel "paystubs" job, and we weren't
filtering them out of the results correctly due to a bug.

The issue here is that we were encoding the API request parameters
incorrectly, as:

  POST /v1/search?q=foo&required_jobs[]=paystubs

The correct way to encode the `required_jobs` URL param, per API docs,
is:

  POST /v1/search?q=foo&required_jobs=paystubs

(any additional values in the required_jobs array would be passed as
repeated parameters)

I ran some metrics: 6% of Pinwheel's 2620 employers will be filtered out
as a result. The biggest ones that I saw were USPS, Walgreens, Duane
Reade, and Harris Teeter.

Finishes FFS-952.
  • Loading branch information
tdooner committed Jun 28, 2024
1 parent 53cb0f1 commit 5a42ed6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/app/services/pinwheel_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def initialize(api_key = ENV["PINWHEEL_API_TOKEN"])
client_options = {
request: {
open_timeout: 5,
timeout: 5
timeout: 5,
# Pinwheel requires repeated params (i.e. `{ foo: [1, 2, 3] }`) to
# be serialized as `?foo=1&foo=2&foo=3`:
params_encoder: Faraday::FlatParamsEncoder
},
url: BASE_URL,
headers: {
Expand Down

0 comments on commit 5a42ed6

Please sign in to comment.