"""Logic for fetching inconsistent records.""" from typing import List from src.common.logic.art_relations import fetch_ar_records_to_sync from src.common.logic.report_fetch import encode_records from src.common.logic.report_fetch import filter_report_type from src.common.logic.report_fetch import get_ids_per_table from src.common.models.metadata import InconsistencyReport from src.common.models.metadata import InconsistencyType from src.common.models.metadata import ReleaseArtistTable def fetch_product_participations_events(inconsistency_reports: List[InconsistencyReport]): """Fetch product participations events.""" inconsistency_report = filter_report_type( inconsistency_reports, InconsistencyType.BAD_PRODUCT_PARTICIPATIONS) pk_ids = get_ids_per_table(inconsistency_report, ReleaseArtistTable) records_to_sync = fetch_ar_records_to_sync(ReleaseArtistTable, pk_ids) return encode_records(records_to_sync)