Optimization: only check allowed for unique programs #240
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It looks to me like you're checking OPA for program ID for every object to be ingested, so if there were 300 treatments in 5 programs, you'd have to call OPA 300 times. If that's the case, no wonder you'd want to check for site admin first, because that would bypass a lot of calls. But if instead you only check for unique program IDs, you'd only have to call OPA 5 times. Even if it's a little wasteful to call it those 4 extra times for the site admin, it's not so bad, and it would simplify the code. I tried to update the comment to help explain the exact behavior.
This is all moot because katsu_ingest.py sorts the ingest file by program first, and ingests only one program at a time, so it will take the same amount of calls (1) whether the user is a site admin or not.
Should behave as before.