Interface ArtistCityRepository

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

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

    • findByArtistIdAndCityId

      Optional<ArtistCity> findByArtistIdAndCityId(UUID artistId, UUID cityId)
      Finds an artist-city relationship by artist ID and city ID.
      Parameters:
      artistId - The ID of the artist.
      cityId - The ID of the city.
      Returns:
      An optional containing the artist-city relationship if found, otherwise empty.
    • findByArtistId

      List<ArtistCity> findByArtistId(UUID artistId)
      Finds all artist-city relationships for an artist.
      Parameters:
      artistId - The ID of the artist.
      Returns:
      A list of artist-city relationships.
    • findByArtistIdAndConfirmedAtNotNullAndBannedAtNull

      List<ArtistCity> findByArtistIdAndConfirmedAtNotNullAndBannedAtNull(UUID artistId)
      Finds all confirmed and not banned artist-city relationships for an artist.
      Parameters:
      artistId - The ID of the artist.
      Returns:
      A list of artist-city relationships.
    • findByCityId

      org.springframework.data.domain.Page<ArtistCity> findByCityId(UUID cityId, org.springframework.data.domain.Pageable req)
      Finds a page of artist-city relationships for a city.
      Parameters:
      cityId - The ID of the city.
      req - The pageable request.
      Returns:
      A page of artist-city relationships.
    • findByCityIdAndConfirmedAtNotNull

      org.springframework.data.domain.Page<ArtistCity> findByCityIdAndConfirmedAtNotNull(UUID cityId, org.springframework.data.domain.Pageable req)
      Finds a page of confirmed artist-city relationships for a city.
      Parameters:
      cityId - The ID of the city.
      req - The pageable request.
      Returns:
      A page of artist-city relationships.
    • addArtistCity

      @Modifying @Query(value="insert into artist_cities (artist_id, city_id) values (:artistId, :cityId) on conflict do nothing", nativeQuery=true) void addArtistCity(UUID artistId, UUID cityId)
      Adds a new artist-city relationship.
      Parameters:
      artistId - The ID of the artist.
      cityId - The ID of the city.
    • countByCityId

      Integer countByCityId(UUID cityId)
      Counts the number of artist-city relationships for a city.
      Parameters:
      cityId - The ID of the city.
      Returns:
      The number of artist-city relationships.
    • countByCityIdAndConfirmedAtNotNull

      Integer countByCityIdAndConfirmedAtNotNull(UUID cityId)
      Counts the number of confirmed artist-city relationships for a city.
      Parameters:
      cityId - The ID of the city.
      Returns:
      The number of confirmed artist-city relationships.
    • findByCityIdAndBannedAtNullAndConfirmedAtNotNullOrderByArtistSpotifyPopularityDesc

      org.springframework.data.domain.Page<ArtistCity> findByCityIdAndBannedAtNullAndConfirmedAtNotNullOrderByArtistSpotifyPopularityDesc(UUID cityId, org.springframework.data.domain.Pageable req)
      Finds a page of not banned and confirmed artist-city relationships for a city, ordered by artist popularity.
      Parameters:
      cityId - The ID of the city.
      req - The pageable request.
      Returns:
      A page of artist-city relationships.
    • findArtistCitiesNearPoint

      @Query("select ac from ArtistCity ac\nwhere st_distance(st_transform(ac.city.geoPoint, 3857), st_transform(:point, 3857)) <= (:radius * 1000)\nand ac.bannedAt is null and ac.confirmedAt is not null\norder by ac.artist.spotifyPopularity desc\n") org.springframework.data.domain.Page<ArtistCity> findArtistCitiesNearPoint(org.locationtech.jts.geom.Point point, Double radius, org.springframework.data.domain.Pageable req)
      Finds artist-city relationships near a geographic point.
      Parameters:
      point - The geographic point.
      radius - The search radius in kilometers.
      req - The pageable request.
      Returns:
      A page of artist-city relationships.
    • orderArtistCities

      @Query("select ac from ArtistCity ac where ac.artist.id = :artistId and not ac.city.isUniversity order by st_distance(st_transform(ac.city.geoPoint, 3857), st_transform(:point, 3857))") List<ArtistCity> orderArtistCities(UUID artistId, org.locationtech.jts.geom.Point point)
      Finds all artist-city relationships for an artist, ordered by distance to a geographic point.
      Parameters:
      artistId - The ID of the artist.
      point - The geographic point.
      Returns:
      A list of artist-city relationships.
    • findAllByConfirmedAtNullAndBannedAtNullAndContributedByNotNull

      org.springframework.data.domain.Page<ArtistCity> findAllByConfirmedAtNullAndBannedAtNullAndContributedByNotNull(org.springframework.data.domain.Pageable req)
      Finds a page of unconfirmed, not banned, and contributed artist-city relationships.
      Parameters:
      req - The pageable request.
      Returns:
      A page of artist-city relationships.
    • countByContributedByAndConfirmedAtNotNullAndBannedAtNull

      Integer countByContributedByAndConfirmedAtNotNullAndBannedAtNull(User user)
      Counts the number of confirmed and not banned contributions by a user.
      Parameters:
      user - The user.
      Returns:
      The number of contributions.
    • countByContributedByAndBannedAtNotNull

      Integer countByContributedByAndBannedAtNotNull(User user)
      Counts the number of banned contributions by a user.
      Parameters:
      user - The user.
      Returns:
      The number of contributions.
    • findByArtistIdAndClosestGeoPoint

      @Query("select ac from ArtistCity ac\nwhere ac.bannedAt is null and ac.confirmedAt is not null\nand ac.artist.id = :artistId\norder by st_distance(ac.city.geoPoint, :point)\nlimit 1\n") Optional<ArtistCity> findByArtistIdAndClosestGeoPoint(UUID artistId, org.locationtech.jts.geom.Point point)
      Finds the closest artist-city relationship for an artist to a geographic point.
      Parameters:
      artistId - The ID of the artist.
      point - The geographic point.
      Returns:
      An optional containing the artist-city relationship if found, otherwise empty.
    • countByCreatedAtBetweenAndContributedByNotNull

      @Async CompletableFuture<Long> countByCreatedAtBetweenAndContributedByNotNull(Instant start, Instant end)
      Counts the number of contributed artist-city relationships created between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of contributions.
    • countByCreatedAtBetweenAndContributedByNotNullAndConfirmedAtNotNull

      @Async CompletableFuture<Long> countByCreatedAtBetweenAndContributedByNotNullAndConfirmedAtNotNull(Instant start, Instant end)
      Counts the number of confirmed and contributed artist-city relationships created between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of contributions.
    • findTopByOrderByCreatedAt

      ArtistCity findTopByOrderByCreatedAt()
      Finds the most recently created artist-city relationship.
      Returns:
      The artist-city relationship.
    • countByConfirmedAtNotNullAndBannedAtNull

      @Async CompletableFuture<Integer> countByConfirmedAtNotNullAndBannedAtNull()
      Counts the number of confirmed and not banned artist-city relationships.
      Returns:
      A completable future containing the number of relationships.
    • countCitiesByConfirmedAtNotNullAndBannedAtNull

      @Async @Query("select count(distinct ac.artist) from ArtistCity ac where ac.confirmedAt is not null and ac.bannedAt is null") CompletableFuture<Integer> countCitiesByConfirmedAtNotNullAndBannedAtNull()
      Counts the number of distinct artists with confirmed and not banned artist-city relationships.
      Returns:
      A completable future containing the number of artists.