from flask import g, request from auth.auth_view import AuthorizedView from artists.schemas import ArtistRequestModel from utils.handlers import get_request_query_model from artists.services.artists_service import ArtistsService from utils.test_helpers import sync from services.recent_search.recent_search_service import RecentSearchesService class ArtistsView(AuthorizedView): artists_service: ArtistsService = ArtistsService() @sync async def get(self): model = get_request_query_model(ArtistRequestModel) return await self.artists_service.get_artists_by_name(model.query, model.limit) class ArtistView(AuthorizedView): artists_service: ArtistsService = ArtistsService() recent_search_service = RecentSearchesService() @sync async def get(self, artist_external_id: str): artist = await self.artists_service.get_artist_by_id(artist_external_id) self.recent_search_service.track_opened_artist_details(artist_external_id, g.user_id, request.args) return artist