Interface ArtistRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Artist,UUID>, org.springframework.data.jpa.repository.JpaRepository<Artist,UUID>, org.springframework.data.repository.ListCrudRepository<Artist,UUID>, org.springframework.data.repository.ListPagingAndSortingRepository<Artist,UUID>, org.springframework.data.repository.PagingAndSortingRepository<Artist,UUID>, org.springframework.data.repository.query.QueryByExampleExecutor<Artist>, org.springframework.data.repository.Repository<Artist,UUID>

@Repository public interface ArtistRepository extends org.springframework.data.jpa.repository.JpaRepository<Artist,UUID>
Repository for Artist entities.
  • Method Details

    • getBitFoundArtistsUpdatedOlderThan

      @Query("select a from Artist a where a.bandsInTownId is not null and a.bandsInTownUpdatedAt <= :newest\nand (a.bandsInTownQueuedAt is null or a.bandsInTownQueuedAt <= :newest)\n") List<Artist> getBitFoundArtistsUpdatedOlderThan(Instant newest, org.springframework.data.domain.Pageable pageable)
      Gets a list of artists found on BandsInTown that were updated before a certain time.
      Parameters:
      newest - The timestamp to check against.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getBitNotSearchedArtists

      @Query("select a from Artist a\n where a.bandsInTownId is null\n and a.bandsInTownFound is null\n and a.bandsInTownQueuedAt is null\norder by a.spotifyPopularity desc\n") List<Artist> getBitNotSearchedArtists(org.springframework.data.domain.Pageable pageable)
      Gets artists that have not yet been searched on BandsInTown.
      Parameters:
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getBitNotFoundArtists

      @Query("select a from Artist a\n where a.bandsInTownId is null\n and a.bandsInTownFound = false\n and a.bandsInTownQueuedAt is not null\n and a.bandsInTownQueuedAt <= :newest\norder by a.spotifyPopularity desc\n") List<Artist> getBitNotFoundArtists(Instant newest, org.springframework.data.domain.Pageable pageable)
      Gets artists that have not been found on BandsInTown.
      Parameters:
      newest - The timestamp to check against.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getPollstarFoundArtistsUpdatedOlderThan

      @Query("select a from Artist a\n where a.pollstarId is not null\n and a.pollstarUpdatedAt <= :newest\n and a.pollstarQueuedAt <= :newest\norder by a.spotifyPopularity desc nulls last\n") List<Artist> getPollstarFoundArtistsUpdatedOlderThan(Instant newest, org.springframework.data.domain.Pageable pageable)
      Gets a list of artists found on Pollstar that were updated before a certain time.
      Parameters:
      newest - The timestamp to check against.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getPollstarUpdatedOlderThan

      @Query("select a from Artist a where a.pollstarId is not null and a.pollstarUpdatedAt <= :newest\nand (a.pollstarQueuedAt is null or a.pollstarQueuedAt <= :newest)\n") List<Artist> getPollstarUpdatedOlderThan(Instant newest, org.springframework.data.domain.Pageable pageable)
      Gets a list of artists on Pollstar that were updated before a certain time.
      Parameters:
      newest - The timestamp to check against.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getPollstarNotSearchedArtists

      @Query("select a from Artist a\n where a.pollstarQueuedAt is null\norder by a.spotifyPopularity desc nulls last\n") List<Artist> getPollstarNotSearchedArtists(org.springframework.data.domain.Pageable pageable)
      Gets artists that have not yet been searched on Pollstar.
      Parameters:
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getPollstarNotFoundArtists

      @Query("select a from Artist a\n where a.pollstarId is null\n and a.pollstarUpdatedAt is null\n and a.pollstarQueuedAt is not null\n and a.pollstarQueuedAt <= :newest\norder by a.spotifyPopularity desc nulls last\n") List<Artist> getPollstarNotFoundArtists(Instant newest, org.springframework.data.domain.Pageable pageable)
      Gets artists that have not been found on Pollstar.
      Parameters:
      newest - The timestamp to check against.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getNotFoundSimilarities

      @Query(value="select id from artists left join artist_similarity ars on artists.id = ars.seed_artist_id where similar_artist_id is null", nativeQuery=true) List<UUID> getNotFoundSimilarities()
      Gets a list of artist IDs that have no similar artists.
      Returns:
      A list of artist IDs.
    • getNumSongs

      @Query("select count(a) from ArtistSong a where a.artist.id = :artistId ") int getNumSongs(UUID artistId)
      Gets the number of songs for an artist.
      Parameters:
      artistId - The ID of the artist.
      Returns:
      The number of songs.
    • getNumSimilarArtists

      @Query("select count(a) from ArtistSimilarity a where a.seedArtist.id = :artistId ") int getNumSimilarArtists(UUID artistId)
      Gets the number of similar artists for an artist.
      Parameters:
      artistId - The ID of the artist.
      Returns:
      The number of similar artists.
    • getArtistsNewerThan

      @Query("select a from Artist a where a.createdAt >= :time and a.spotifyUpdatedAt is null") List<Artist> getArtistsNewerThan(Instant time)
      Gets a list of artists created after a certain time that have not been updated from Spotify.
      Parameters:
      time - The timestamp to check against.
      Returns:
      A list of artists.
    • getLocalArtists

      @Query("select ac.artist from ArtistCity ac where ac.confirmedAt is not null") List<Artist> getLocalArtists(UUID cityId)
      Gets a list of local artists for a city.
      Parameters:
      cityId - The ID of the city.
      Returns:
      A list of artists.
    • getLocalArtistIds

      @Query("select ac.artist.id from ArtistCity ac where ac.city.id = :cityId and ac.confirmedAt is not null") List<UUID> getLocalArtistIds(UUID cityId)
      Gets a list of local artist IDs for a city.
      Parameters:
      cityId - The ID of the city.
      Returns:
      A list of artist IDs.
    • getSpotifyArtistsUpdatedOlderThan

      @Query("select a from Artist a where a.spotifyId is not null and (a.spotifyEventsUpdatedAt <= :newest or a.spotifyEventsUpdatedAt is null)\nand (a.spotifyQueuedAt is null or a.spotifyQueuedAt <= :newest)\n") List<Artist> getSpotifyArtistsUpdatedOlderThan(Instant newest, org.springframework.data.domain.Pageable pageable)
      Gets a list of Spotify artists whose events were updated before a certain time.
      Parameters:
      newest - The timestamp to check against.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getSpotifyArtistsUpdatedFromApiOlderThan

      @Query("select a from Artist a where a.spotifyId is not null and (a.spotifyUpdatedAt <= :newest or a.spotifyUpdatedAt is null)\n") List<Artist> getSpotifyArtistsUpdatedFromApiOlderThan(Instant newest, org.springframework.data.domain.Pageable pageable)
      Gets a list of Spotify artists that were updated from the API before a certain time.
      Parameters:
      newest - The timestamp to check against.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getLocalArtistIdsByPoint

      @Query(value="select distinct a.id\nfrom artists a\njoin artist_cities ac on a.id = ac.artist_id\njoin cities c on ac.city_id = c.id\nwhere st_distance(st_transform(c.geo_point, 3857), st_transform(:point, 3857)) / 1000 <= :radius\nand ac.confirmed_at is not null and ac.banned_at is null\n", nativeQuery=true) List<UUID> getLocalArtistIdsByPoint(org.locationtech.jts.geom.Point point, Double radius)
      Gets a list of local artist IDs near a geographic point.
      Parameters:
      point - The geographic point.
      radius - The search radius in kilometers.
      Returns:
      A list of artist IDs.
    • getBandsInTownNotScrapedAndFoundNullOrFalse

      @Query("select a from Artist a where a.bandsInTownId is null\nand (a.bandsInTownFound is null or a.bandsInTownFound = false)\norder by a.bandsInTownQueuedAt asc nulls first\n") List<Artist> getBandsInTownNotScrapedAndFoundNullOrFalse(org.springframework.data.domain.Pageable pageable)
      Gets a list of artists that have not been scraped from BandsInTown and have not been found.
      Parameters:
      pageable - The pageable request.
      Returns:
      A list of artists.
    • findBySpotifyTopTrackPreviewNullOrderBySpotifyTopTrackFailedAt

      @Query("select a from Artist a\nwhere a.spotifyTopTrackPreview is null\norder by a.spotifyTopTrackFailedAt asc nulls first\n") List<Artist> findBySpotifyTopTrackPreviewNullOrderBySpotifyTopTrackFailedAt(org.springframework.data.domain.Pageable pageable)
      Finds artists with a null Spotify top track preview, ordered by the time the fetch failed.
      Parameters:
      pageable - The pageable request.
      Returns:
      A list of artists.
    • findByBandsInTownId

      Optional<Artist> findByBandsInTownId(String bitId)
      Finds an artist by their BandsInTown ID.
      Parameters:
      bitId - The BandsInTown ID.
      Returns:
      An optional containing the artist if found, otherwise empty.
    • findByPollstarId

      Optional<Artist> findByPollstarId(String pollstarId)
      Finds an artist by their Pollstar ID.
      Parameters:
      pollstarId - The Pollstar ID.
      Returns:
      An optional containing the artist if found, otherwise empty.
    • findBySpotifyId

      Optional<Artist> findBySpotifyId(String spotifyId)
      Finds an artist by their Spotify ID.
      Parameters:
      spotifyId - The Spotify ID.
      Returns:
      An optional containing the artist if found, otherwise empty.
    • findByNameNativeBoostedPopularity

      @Query(value="WITH filtered_rows AS (\n SELECT *, CASE\n WHEN name ILIKE :name THEN (spotify_popularity / 100.0) * 5.0 + 1.0\n WHEN name ILIKE :name || \'%\' THEN (spotify_popularity / 100.0) * 1.5 + 1.0\n ELSE (spotify_popularity / 100.0) + 1.0\n END AS boosted_popularity\n FROM artists\n WHERE (name ILIKE :name\n OR name ILIKE \'%\' || :name || \'%\'\n OR name ILIKE :name || \'%\'\n )\n)\nSELECT *\nFROM filtered_rows\nORDER BY\n boosted_popularity DESC,\n ts_rank_cd(to_tsvector(\'english\', name), plainto_tsquery(\'english\', :name)) DESC LIMIT :limit\n", nativeQuery=true) List<Artist> findByNameNativeBoostedPopularity(String name, int limit)
      Finds artists by name using a native query with boosted popularity for exact matches.
      Parameters:
      name - The name to search for.
      limit - The maximum number of results to return.
      Returns:
      A list of artists.
    • findByNameStartsWithNativeBoostedPopularity

      @Query(value="WITH filtered_rows AS (\n SELECT *, CASE\n WHEN name ILIKE :name THEN (spotify_popularity / 100.0) * 5.0 + 1.0\n WHEN name ILIKE :name || \'%\' THEN (spotify_popularity / 100.0) * 1.5 + 1.0\n ELSE (spotify_popularity / 100.0) + 1.0\n END AS boosted_popularity\n FROM artists\n WHERE (name ILIKE :name\n OR name ILIKE :name || \'%\'\n )\n)\nSELECT *\nFROM filtered_rows\nORDER BY\n boosted_popularity DESC,\n ts_rank_cd(to_tsvector(\'english\', name), plainto_tsquery(\'english\', :name)) DESC LIMIT :limit\n", nativeQuery=true) List<Artist> findByNameStartsWithNativeBoostedPopularity(String name, int limit)
      Finds artists by name (starts with) using a native query with boosted popularity for exact matches.
      Parameters:
      name - The name to search for.
      limit - The maximum number of results to return.
      Returns:
      A list of artists.
    • findByName

      org.springframework.data.domain.Page<Artist> findByName(String name, org.springframework.data.domain.Pageable pageable)
      Finds a page of artists by name.
      Parameters:
      name - The name to search for.
      pageable - The pageable request.
      Returns:
      A page of artists.
    • findByName

      List<Artist> findByName(String name)
      Finds a list of artists by name.
      Parameters:
      name - The name to search for.
      Returns:
      A list of artists.
    • findRandom

      @Query(value="select * from artists order by random() limit :limit", nativeQuery=true) List<Artist> findRandom(int limit)
      Finds a list of random artists.
      Parameters:
      limit - The maximum number of artists to return.
      Returns:
      A list of random artists.
    • findArtistBySpotifyPopularityBetween

      @Query List<Artist> findArtistBySpotifyPopularityBetween(int minPopularity, int maxPopularity)
      Finds artists with Spotify popularity between a given range.
      Parameters:
      minPopularity - The minimum popularity.
      maxPopularity - The maximum popularity.
      Returns:
      A list of artists.
    • getTopArtistsForGenre

      @Query("select ag.artist from ArtistGenre ag where ag.genre.id = :genreId order by ag.artist.spotifyPopularity desc") List<Artist> getTopArtistsForGenre(UUID genreId, org.springframework.data.domain.Pageable pageable)
      Gets the top artists for a genre.
      Parameters:
      genreId - The ID of the genre.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • getCuratedArtistsForGenre

      @Query("select ag.artist from ArtistGenre ag where ag.genre.id = :genreId and ag.isEmblematic order by ag.emblemPlacement") List<Artist> getCuratedArtistsForGenre(UUID genreId)
      Gets the curated artists for a genre.
      Parameters:
      genreId - The ID of the genre.
      Returns:
      A list of artists.
    • findPopularArtistsByGenres

      @Query("select ag.artist from ArtistGenre ag left join fetch ag.artist.genres where ag.genre.id in :genreIds and ag.artist.spotifyPopularity > :popularity order by ag.artist.spotifyPopularity desc") List<Artist> findPopularArtistsByGenres(List<UUID> genreIds, int popularity, org.springframework.data.domain.Pageable pageable)
      Finds popular artists by a list of genres.
      Parameters:
      genreIds - The list of genre IDs.
      popularity - The minimum popularity.
      pageable - The pageable request.
      Returns:
      A list of artists.
    • findPopularArtistsForGenre

      @Query("select ag.artist from ArtistGenre ag where ag.genre.id = :genreId and ag.score > :threshold order by ag.artist.spotifyPopularity DESC") List<Artist> findPopularArtistsForGenre(UUID genreId, org.springframework.data.domain.Pageable pageable, double threshold)
      Finds popular artists for a genre with a score above a certain threshold.
      Parameters:
      genreId - The ID of the genre.
      pageable - The pageable request.
      threshold - The score threshold.
      Returns:
      A list of artists.
    • getNameForArtist

      @Query("select a.name from Artist a where a.id = :artistId") String getNameForArtist(UUID artistId)
      Gets the name of an artist by their ID.
      Parameters:
      artistId - The ID of the artist.
      Returns:
      The name of the artist.
    • findByAppleId

      Artist findByAppleId(String appleId)
      Finds an artist by their Apple Music ID.
      Parameters:
      appleId - The Apple Music ID.
      Returns:
      The artist.
    • getSimilarArtists

      @Query("select ars.similarArtist from ArtistSimilarity ars where ars.seedArtist.id = :artistId order by ars.score desc") List<Artist> getSimilarArtists(UUID artistId, org.springframework.data.domain.Pageable pageable)
      Gets a list of similar artists for an artist.
      Parameters:
      artistId - The ID of the artist.
      pageable - The pageable request.
      Returns:
      A list of similar artists.
    • countAllByCreatedAtAfter

      @Async CompletableFuture<Long> countAllByCreatedAtAfter(Instant after)
      Counts all artists created after a certain time.
      Parameters:
      after - The timestamp to check against.
      Returns:
      A completable future containing the number of artists.
    • addSpotifyArtist

      @Modifying @Transactional @Query(value="insert into artists (id, name, spotify_id, spotify_popularity, spotify_image, spotify_updated_at, created_at, updated_at) values (gen_random_uuid(), :name, :spotifyId, :spotifyPopularity, :spotifyImage, current_timestamp, current_timestamp, current_timestamp) on conflict do nothing", nativeQuery=true) void addSpotifyArtist(String name, String spotifyId, Integer spotifyPopularity, String spotifyImage)
      Adds a new Spotify artist.
      Parameters:
      name - The name of the artist.
      spotifyId - The Spotify ID of the artist.
      spotifyPopularity - The Spotify popularity of the artist.
      spotifyImage - The Spotify image URL of the artist.
    • findTopByOrderByCreatedAt

      Artist findTopByOrderByCreatedAt()
      Finds the most recently created artist.
      Returns:
      The artist.
    • countBySpotifyUpdatedAtBetween

      @Async CompletableFuture<Long> countBySpotifyUpdatedAtBetween(Instant start, Instant end)
      Counts the number of artists updated from Spotify between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of artists.
    • countByBandsInTownUpdatedAtBetween

      @Async CompletableFuture<Long> countByBandsInTownUpdatedAtBetween(Instant start, Instant end)
      Counts the number of artists updated from BandsInTown between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of artists.
    • countByPollstarUpdatedAtBetween

      @Async CompletableFuture<Long> countByPollstarUpdatedAtBetween(Instant start, Instant end)
      Counts the number of artists updated from Pollstar between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of artists.
    • countByCreatedAtBetweenAndSpotifyUpdatedAtNotNull

      @Async CompletableFuture<Long> countByCreatedAtBetweenAndSpotifyUpdatedAtNotNull(Instant start, Instant end)
      Counts the number of artists created between two timestamps that have been updated from Spotify.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of artists.
    • countByCreatedAtBetweenAndBandsInTownUpdatedAtNotNull

      @Async CompletableFuture<Long> countByCreatedAtBetweenAndBandsInTownUpdatedAtNotNull(Instant start, Instant end)
      Counts the number of artists created between two timestamps that have been updated from BandsInTown.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of artists.
    • countByCreatedAtBetweenAndPollstarUpdatedAtNotNull

      @Async CompletableFuture<Long> countByCreatedAtBetweenAndPollstarUpdatedAtNotNull(Instant start, Instant end)
      Counts the number of artists created between two timestamps that have been updated from Pollstar.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of artists.
    • getArtistFromId

      @Query("select a from Artist a where a.id = :id") Artist getArtistFromId(UUID id)
      Gets an artist by their ID.
      Parameters:
      id - The ID of the artist.
      Returns:
      The artist.