import decimal from anydi import singleton from dmp.adapters.db import ReportingDB @singleton class ArtistMaxSpendRepository: def __init__(self, db: ReportingDB) -> None: self.db = db def get_max_spend( self, vendor_id: int | None, subaccount_id: int | None, global_participant_ids: list[str], is_global: bool = False, ) -> decimal.Decimal: query = self.db.query_from_template( "artist/get-artist-max-spend.sql", context={ "vendor_id": vendor_id, "subaccount_id": subaccount_id, "global_participant_ids": global_participant_ids, "is_global": is_global, }, ) return decimal.Decimal(self.db.session.execute(query).scalar_one_or_none() or 0)