Package org.localify.repositories
Interface VenueRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Venue,,UUID> org.springframework.data.jpa.repository.JpaRepository<Venue,,UUID> org.springframework.data.repository.ListCrudRepository<Venue,,UUID> org.springframework.data.repository.ListPagingAndSortingRepository<Venue,,UUID> org.springframework.data.repository.PagingAndSortingRepository<Venue,,UUID> org.springframework.data.repository.query.QueryByExampleExecutor<Venue>,org.springframework.data.repository.Repository<Venue,UUID>
public interface VenueRepository
extends org.springframework.data.jpa.repository.JpaRepository<Venue,UUID>
Repository for
Venue entities.-
Method Summary
Modifier and TypeMethodDescriptioncountByCityId(UUID cityId) Counts the number of venues in a city.countByEventStartTimeAfter(Instant startTime) Counts the number of distinct venues with events after a certain time.org.springframework.data.domain.Page<Venue>findAllByCityId(UUID cityId, org.springframework.data.domain.Pageable pageable) Finds a page of venues for a city.org.springframework.data.domain.Page<Venue>findAllByCityIdOrderByEventCountDesc(UUID cityId, org.springframework.data.domain.Pageable pageable) Finds a page of venues for a city, ordered by the number of upcoming events.org.springframework.data.domain.Page<Venue>findAllByCityIdOrderByEventCountDescExcludeBadVenues(UUID cityId, Instant oneYearAgo, org.springframework.data.domain.Pageable pageable) Finds a page of venues for a city, ordered by the number of upcoming events, excluding venues with no events in the last year.Finds all venues that have a playlist.findByBandsInTownId(String bitId) Finds a venue by its BandsInTown ID.findByName(String name, int limit) Finds venues by name.findByPollstarId(String pollstarId) Finds a venue by its Pollstar ID.findNearbyByName(org.locationtech.jts.geom.Point point, String matching, double tolerance, int limit) Finds nearby venues by name.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByBandsInTownId
Finds a venue by its BandsInTown ID.- Parameters:
bitId- The BandsInTown ID.- Returns:
- The venue.
-
findByPollstarId
Finds a venue by its Pollstar ID.- Parameters:
pollstarId- The Pollstar ID.- Returns:
- An optional containing the venue if found, otherwise empty.
-
findByName
@Query(value="select v.* from venues v where unaccent(v.name) ilike concat(\'%\', :name, \'%\') order by similarity(v.name, :name) desc limit :limit", nativeQuery=true) List<Venue> findByName(String name, int limit) Finds venues by name.- Parameters:
name- The name of the venue.limit- The maximum number of results to return.- Returns:
- A list of venues.
-
findNearbyByName
@Query(value="select v.*\nfrom venues v\nwhere name ilike :matching\nand st_dwithin(v.geog, :point, :tolerance)\nlimit :limit\n", nativeQuery=true) List<Venue> findNearbyByName(org.locationtech.jts.geom.Point point, String matching, double tolerance, int limit) Finds nearby venues by name.- Parameters:
point- The geographic point to search near.matching- The name to match.tolerance- The search radius in meters.limit- The maximum number of results to return.- Returns:
- A list of venues.
-
findAllByPlaylistNotNull
Finds all venues that have a playlist.- Returns:
- A list of venues.
-
findAllByCityId
org.springframework.data.domain.Page<Venue> findAllByCityId(UUID cityId, org.springframework.data.domain.Pageable pageable) Finds a page of venues for a city.- Parameters:
cityId- The ID of the city.pageable- The pageable request.- Returns:
- A page of venues.
-
findAllByCityIdOrderByEventCountDesc
@Query("select v from Venue v left join Event e on v.id = e.venue.id and e.startTime > current_timestamp where v.city.id = :cityId group by v.id order by count(e.id) desc") org.springframework.data.domain.Page<Venue> findAllByCityIdOrderByEventCountDesc(UUID cityId, org.springframework.data.domain.Pageable pageable) Finds a page of venues for a city, ordered by the number of upcoming events.- Parameters:
cityId- The ID of the city.pageable- The pageable request.- Returns:
- A page of venues.
-
findAllByCityIdOrderByEventCountDescExcludeBadVenues
@Query("select v from Venue v left join Event e on v.id = e.venue.id and e.startTime > current_timestamp where v.city.id = :cityId and v.id in (select v.id from Venue v join Event e on v.id = e.venue.id and e.startTime > :oneYearAgo) group by v.id order by count(e.id) desc") org.springframework.data.domain.Page<Venue> findAllByCityIdOrderByEventCountDescExcludeBadVenues(UUID cityId, Instant oneYearAgo, org.springframework.data.domain.Pageable pageable) Finds a page of venues for a city, ordered by the number of upcoming events, excluding venues with no events in the last year.- Parameters:
cityId- The ID of the city.oneYearAgo- A timestamp representing one year ago.pageable- The pageable request.- Returns:
- A page of venues.
-
countByCityId
Counts the number of venues in a city.- Parameters:
cityId- The ID of the city.- Returns:
- The number of venues.
-
countByEventStartTimeAfter
@Async @Query("select count(distinct v) from Venue v join Event e on v.id = e.venue.id where e.startTime >= :startTime") CompletableFuture<Integer> countByEventStartTimeAfter(Instant startTime) Counts the number of distinct venues with events after a certain time.- Parameters:
startTime- The minimum start time.- Returns:
- A completable future containing the number of venues.
-