cal-itp / benefits

Transit benefits enrollment, minus the paperwork.
https://docs.calitp.org/benefits
GNU Affero General Public License v3.0
25 stars 9 forks source link

Refactor enrollment check to lookup groups for funding source #2068

Open thekaveman opened 2 months ago

thekaveman commented 2 months ago

When we first implemented enrollment expiration logic in #1989, the only way to check if the user (funding source) was already linked to a group was to look up all funding sources linked to the group, and check if the user's funding source was in the that list. Over time with increasing enrollments, this won't scale as every single funding source will have to be checked each time.

Now Littlepay offers an endpoint to look up the groups linked to a given funding source, i.e. the inverse relationship. See https://github.com/cal-itp/littlepay/issues/60.

This will be a much shorter list to check -- empty for new users (funding sources), and perhaps one or two and not many more for existing users.

Acceptance Criteria

During enrollment:

Additional context

Depends on https://github.com/cal-itp/littlepay/issues/60.

This will be a refactor of the the work that comes back (but may be modified) with #2062.

angela-tran commented 4 weeks ago

I tested out calling the endpoint implemented in https://github.com/cal-itp/littlepay/issues/60 against the MST QA and prod Littlepay environments.

The endpoint returns a 404 status even though I'm giving it a funding source ID that I know is in a group (I can see it when I look up the funding sources for the group).

The response contains this JSON:

{'errors': [{'detail': 'Not found'}]}