from anydi import singleton from pydantic import TypeAdapter from dmp.adapters.db import ReportingDB from dmp.artists.dtos import Label LabelListValidator = TypeAdapter(list[Label]) @singleton class ArtistAccountRepository: def __init__(self, db: ReportingDB) -> None: self.db = db def find_accounts_having_fandata( self, global_participant_id: str, *, vendor_ids: list[int], subaccount_ids: list[int], ) -> list[Label]: query = self.db.query_from_template( "artist/get-accounts.sql", context={ "global_participant_id": global_participant_id, "vendor_ids": vendor_ids, "subaccount_ids": subaccount_ids, }, ) return LabelListValidator.validate_python( self.db.session.execute(query).mappings(), )