from auth.auth_view import AuthorizedView from performance.services.breakdown_options_service import BreakdownOptionsService, BreakdownType class BreakdownOptionsListView(AuthorizedView): service: BreakdownOptionsService = BreakdownOptionsService() def get(self, breakdown_type: str): return self.service.get_sorted_options_list(self.__map_to_enum(breakdown_type)) @staticmethod def __map_to_enum(breakdown_type: str) -> BreakdownType: return { "artists": BreakdownType.ARTISTS, "projects": BreakdownType.PROJECTS, "campaigns": BreakdownType.CAMPAIGNS, "unassigned_campaigns": BreakdownType.UNASSIGNED_CAMPAIGNS, }[breakdown_type]