Skip to content

Commit c6d0394

Browse files
Remove incompatible endpoints for retrieving privilege data
The multi-state license model does not generate privileges that exist in the database, so these endpoints are not needed.
1 parent 9c4415b commit c6d0394

27 files changed

Lines changed: 40 additions & 4616 deletions

File tree

backend/compact-connect/bin/generate_privilege_test_data.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ def main():
470470

471471
# Check if provider already has a privilege for this specific license type in the target state
472472
existing_privileges = provider_user_records.get_privilege_records(
473-
filter_condition=lambda p, license_type=target_license_type: p.jurisdiction == args.privilege_state
474-
and p.licenseType == license_type
473+
filter_condition=lambda p, license_type=target_license_type: (
474+
p.jurisdiction == args.privilege_state and p.licenseType == license_type
475+
)
475476
)
476477
if existing_privileges:
477478
if args.provider_id:

backend/compact-connect/lambdas/python/common/cc_common/data_model/data_client.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,9 @@ def end_military_affiliation(self, compact: str, provider_id: str) -> None:
862862

863863
# Get all military affiliation records that are INITIALIZING or ACTIVE
864864
active_military_affiliation_records = provider_user_records.get_military_affiliation_records(
865-
filter_condition=lambda record: record.status
866-
in [MilitaryAffiliationStatus.INITIALIZING, MilitaryAffiliationStatus.ACTIVE]
865+
filter_condition=lambda record: (
866+
record.status in [MilitaryAffiliationStatus.INITIALIZING, MilitaryAffiliationStatus.ACTIVE]
867+
)
867868
)
868869

869870
# Create provider update record to track the removal of military status fields
@@ -2312,7 +2313,7 @@ def lift_privilege_encumbrance(
23122313

23132314
# Get the privilege record
23142315
privilege_records = provider_user_records.get_privilege_records(
2315-
filter_condition=lambda p: (p.jurisdiction == jurisdiction and p.licenseType == license_type_name)
2316+
filter_condition=lambda p: p.jurisdiction == jurisdiction and p.licenseType == license_type_name
23162317
)
23172318

23182319
if not privilege_records:
@@ -2611,8 +2612,9 @@ def update_provider_home_state_jurisdiction(
26112612

26122613
# Get all privileges for the provider that were not deactivated previously
26132614
all_active_privileges = provider_user_records.get_privilege_records(
2614-
filter_condition=lambda privilege: privilege.homeJurisdictionChangeStatus
2615-
!= HomeJurisdictionChangeStatusEnum.INACTIVE
2615+
filter_condition=lambda privilege: (
2616+
privilege.homeJurisdictionChangeStatus != HomeJurisdictionChangeStatusEnum.INACTIVE
2617+
)
26162618
)
26172619

26182620
if not all_active_privileges:
@@ -2678,8 +2680,9 @@ def update_provider_home_state_jurisdiction(
26782680

26792681
# Get licenses from the current home state
26802682
current_home_state_licenses = provider_user_records.get_license_records(
2681-
filter_condition=lambda license_data: license_data.jurisdiction
2682-
== home_jurisdiction_before_update
2683+
filter_condition=lambda license_data: (
2684+
license_data.jurisdiction == home_jurisdiction_before_update
2685+
)
26832686
)
26842687

26852688
# Get unique license types from all privileges
@@ -2827,8 +2830,10 @@ def _get_privilege_transaction_items_resulting_from_home_jurisdiction_move(
28272830
privileges_for_license_type = [
28282831
privilege
28292832
for privilege in provider_user_records.get_privilege_records(
2830-
filter_condition=lambda p: p.licenseType == license_type
2831-
and p.homeJurisdictionChangeStatus != HomeJurisdictionChangeStatusEnum.INACTIVE
2833+
filter_condition=lambda p: (
2834+
p.licenseType == license_type
2835+
and p.homeJurisdictionChangeStatus != HomeJurisdictionChangeStatusEnum.INACTIVE
2836+
)
28322837
)
28332838
]
28342839

backend/compact-connect/lambdas/python/common/cc_common/data_model/provider_record_util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,9 @@ def find_best_license_in_current_known_licenses(self, jurisdiction: str | None =
712712
else:
713713
# if jurisdiction is not provided, we filter by the user's current home jurisdiction
714714
current_home_jurisdiction_license_records = self.get_license_records(
715-
filter_condition=lambda license_data: license_data.jurisdiction
716-
== self.get_provider_record().currentHomeJurisdiction
715+
filter_condition=lambda license_data: (
716+
license_data.jurisdiction == self.get_provider_record().currentHomeJurisdiction
717+
)
717718
)
718719
# if there are no licenses for their current home jurisdiction, we will search through all licenses
719720
license_records = (

backend/compact-connect/lambdas/python/provider-data-v1/tests/function/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ def _generate_providers(
378378
patch_kwargs['new_callable'] = lambda: date_of_update
379379
else:
380380
# Use random dates for variation
381-
patch_kwargs['new_callable'] = lambda: datetime.now(tz=UTC).replace(microsecond=0) - timedelta(
382-
days=randint(1, 365)
381+
patch_kwargs['new_callable'] = lambda: (
382+
datetime.now(tz=UTC).replace(microsecond=0) - timedelta(days=randint(1, 365))
383383
)
384384

385385
with patch(

backend/compact-connect/lambdas/python/purchases/handlers/privileges.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,9 @@ def post_purchase_privileges(event: dict, context: LambdaContext): # noqa: ARG0
283283
# Check for any adverse actions that have been lifted 2 years ago
284284
latest_allowed_encumbrance_lift = _get_latest_allowed_encumbrance_lift()
285285
blocking_encumbrance_records = provider_user_records.get_adverse_action_records(
286-
filter_condition=lambda record: record.effectiveLiftDate is None
287-
or record.effectiveLiftDate > latest_allowed_encumbrance_lift
286+
filter_condition=lambda record: (
287+
record.effectiveLiftDate is None or record.effectiveLiftDate > latest_allowed_encumbrance_lift
288+
)
288289
)
289290
if blocking_encumbrance_records:
290291
raise CCInvalidRequestException(
@@ -293,9 +294,11 @@ def post_purchase_privileges(event: dict, context: LambdaContext): # noqa: ARG0
293294

294295
# we now validate that the license type matches one of the license types from the home state license records
295296
matching_license_records = provider_user_records.get_license_records(
296-
filter_condition=lambda record: record.licenseType == body['licenseType']
297-
and record.jurisdiction == current_home_jurisdiction
298-
and record.compactEligibility == CompactEligibilityStatus.ELIGIBLE,
297+
filter_condition=lambda record: (
298+
record.licenseType == body['licenseType']
299+
and record.jurisdiction == current_home_jurisdiction
300+
and record.compactEligibility == CompactEligibilityStatus.ELIGIBLE
301+
),
299302
)
300303

301304
if not matching_license_records:

0 commit comments

Comments
 (0)