Package org.localify.repositories
Interface EventRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Event,,UUID> org.springframework.data.repository.Repository<Event,UUID>
@Repository
public interface EventRepository
extends org.springframework.data.repository.CrudRepository<Event,UUID>
Repository for
Event entities.-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new event.countByBandsInTownUpdatedAtBetween(Instant start, Instant end) Counts the number of events updated from BandsInTown between two timestamps.countByCityIdAfter(UUID cityId, Instant startTime) Counts the number of events in a city after a certain time.countByCreatedAtBeforeAndStartTimeAfter(Instant before, Instant after) Counts the number of events created before a certain time that start after a certain time.Counts the number of events created between two timestamps that have been updated from BandsInTown.Counts the number of events created between two timestamps that have been updated from Google.Counts the number of events created between two timestamps that have been updated from Pollstar.Counts the number of events created between two timestamps that have been updated from Spotify.countByGoogleUpdatedAtBetween(Instant start, Instant end) Counts the number of events updated from Google between two timestamps.countByPollstarUpdatedAtBetween(Instant start, Instant end) Counts the number of events updated from Pollstar between two timestamps.countBySpotifyUpdatedAtBetween(Instant start, Instant end) Counts the number of events updated from Spotify between two timestamps.countByStartTimeAfter(Instant after) Counts the number of events starting after a certain time.intcountByVenueIdAndStartTimeAfter(UUID venueId, Instant after) Counts the number of events for a venue after a certain time.findByArtistAndVenueAndStartTime(UUID artistId, UUID venueId, Instant min, Instant max) Finds events by artist, venue, and start time between two timestamps.findByBandsInTownId(String bitId) Finds an event by its BandsInTown ID.findByEventNameNativeAndDoorTimeGreaterThanEqual(String name, Instant doorTime, int limit) Finds events by name and door time greater than or equal to a certain time.findByNameAndVenue(String name, UUID venueId) Finds events by name and venue.findByNameAndVenueAndStartTimeBetween(String name, UUID venueId, Instant min, Instant max) Finds events by name, venue, and start time between two timestamps.findByPollstarId(String pollstarId) Finds an event by its Pollstar ID.org.springframework.data.domain.Page<Event>findEventsByVenueIdAndStartTimeAfterOrderByStartTimeAsc(UUID venueId, Instant startTime, org.springframework.data.domain.Pageable pageable) Finds events for a venue after a certain time, ordered by start time.org.springframework.data.domain.Page<Event>findEventsByVenueIdAndStartTimeBeforeOrderByStartTimeAsc(UUID venueId, Instant startTime, org.springframework.data.domain.Pageable pageable) Finds events for a venue before a certain time, ordered by start time.org.springframework.data.domain.Page<Event>findEventsForArtist(UUID artistId, Instant minimumStartTime, org.springframework.data.domain.Pageable pageable) Finds events for an artist.org.springframework.data.domain.Page<Event>findEventsForArtistFar(UUID artistId, Instant minimumStartTime, org.locationtech.jts.geom.Point point, Double radius, org.springframework.data.domain.Pageable pageable) Finds events for an artist far from a geographic point.org.springframework.data.domain.Page<Event>findEventsForArtistNear(UUID artistId, Instant minimumStartTime, org.locationtech.jts.geom.Point point, Double radius, org.springframework.data.domain.Pageable pageable) Finds events for an artist near a geographic point.org.springframework.data.domain.Page<Event>findEventsForArtistOrderByStartTime(UUID artistId, Instant minimumStartTime, org.springframework.data.domain.Pageable pageable) Finds events for an artist, ordered by start time.org.springframework.data.domain.Page<Event>findEventsForCity(UUID cityId, Instant minimumStartTime, org.springframework.data.domain.Pageable pageable) Finds events for a city.findNearbyEvents(org.locationtech.jts.geom.Point point, Instant minStartDate, double tolerance, int limit) Finds nearby events.findNearbyEventsBetween(org.locationtech.jts.geom.Point point, Instant minStartDate, Instant maxStartDate, double tolerance, int limit) Finds nearby events between two dates.findNotNullBitIds(Instant time) Finds events with a non-null BandsInTown ID created after a certain time.org.springframework.data.domain.Page<Artist>findTopArtistsForEvent(UUID eventId, org.springframework.data.domain.Pageable pageable) Finds the top artists for an event.Finds the most recently created event.getBitFoundEventsUpdatedOlderThan(Instant time, org.springframework.data.domain.Pageable pageable) Gets a list of events found on BandsInTown that were updated before a certain time.getPollstarFoundEventsUpdatedOlderThan(Instant time, org.springframework.data.domain.Pageable pageable) Gets a list of events found on Pollstar that were updated before a certain time.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findAll, findAllById, findById, save, saveAll
-
Method Details
-
findNearbyEvents
@Query(value="select e.*\nfrom events e\njoin venues v on e.venue_id = v.id\nwhere e.banned_at is null and\n e.start_time >= :minStartDate\nand st_dwithin(v.geog, :point, :tolerance)\nlimit :limit\n", nativeQuery=true) List<Event> findNearbyEvents(org.locationtech.jts.geom.Point point, Instant minStartDate, double tolerance, int limit) Finds nearby events.- Parameters:
point- The geographic point to search near.minStartDate- The minimum start date for events.tolerance- The search radius in meters.limit- The maximum number of results to return.- Returns:
- A list of events.
-
findNearbyEventsBetween
@Query(value="select e.*\nfrom events e\njoin venues v on e.venue_id = v.id\nwhere e.banned_at is null and\n e.start_time >= :minStartDate and\n e.start_time <= :maxStartDate\nand st_dwithin(v.geog, :point, :tolerance)\nlimit :limit\n", nativeQuery=true) List<Event> findNearbyEventsBetween(org.locationtech.jts.geom.Point point, Instant minStartDate, Instant maxStartDate, double tolerance, int limit) Finds nearby events between two dates.- Parameters:
point- The geographic point to search near.minStartDate- The minimum start date for events.maxStartDate- The maximum start date for events.tolerance- The search radius in meters.limit- The maximum number of results to return.- Returns:
- A list of events.
-
getBitFoundEventsUpdatedOlderThan
@Query("select e from Event e where e.bandsInTownId is not null and e.bandsInTownUpdatedAt <= :time\nand (e.bandsInTownQueuedAt is null or e.bandsInTownQueuedAt <= :time)\n") List<Event> getBitFoundEventsUpdatedOlderThan(Instant time, org.springframework.data.domain.Pageable pageable) Gets a list of events found on BandsInTown that were updated before a certain time.- Parameters:
time- The timestamp to check against.pageable- The pageable request.- Returns:
- A list of events.
-
getPollstarFoundEventsUpdatedOlderThan
@Query("select e from Event e where e.pollstarId is not null and e.pollstarUpdatedAt <= :time\nand (e.pollstarQueuedAt is null or e.pollstarQueuedAt <= :time)\n") List<Event> getPollstarFoundEventsUpdatedOlderThan(Instant time, org.springframework.data.domain.Pageable pageable) Gets a list of events found on Pollstar that were updated before a certain time.- Parameters:
time- The timestamp to check against.pageable- The pageable request.- Returns:
- A list of events.
-
findNotNullBitIds
@Query("select e from Event e where e.createdAt >= :time") List<Event> findNotNullBitIds(Instant time) Finds events with a non-null BandsInTown ID created after a certain time.- Parameters:
time- The timestamp to check against.- Returns:
- A list of events.
-
findEventsForArtist
@Query(value="select e.* from events e inner join artist_events ae on e.id = ae.event_id inner join artists a on ae.artist_id = a.id where a.id = :artistId and e.start_time >= :minimumStartTime", nativeQuery=true) org.springframework.data.domain.Page<Event> findEventsForArtist(UUID artistId, Instant minimumStartTime, org.springframework.data.domain.Pageable pageable) Finds events for an artist.- Parameters:
artistId- The ID of the artist.minimumStartTime- The minimum start time for events.pageable- The pageable request.- Returns:
- A page of events.
-
findEventsForArtistNear
@Query(value="select e.* from events e inner join artist_events ae on e.id = ae.event_id inner join artists a on ae.artist_id = a.id inner join venues v on e.venue_id = v.id where a.id = :artistId and e.start_time >= :minimumStartTime and v.geo_point is not null and :point is not null and st_distance(st_transform(v.geo_point, 3857), st_transform(:point, 3857)) <= (:radius * 1000)", nativeQuery=true) org.springframework.data.domain.Page<Event> findEventsForArtistNear(UUID artistId, Instant minimumStartTime, org.locationtech.jts.geom.Point point, Double radius, org.springframework.data.domain.Pageable pageable) Finds events for an artist near a geographic point.- Parameters:
artistId- The ID of the artist.minimumStartTime- The minimum start time for events.point- The geographic point.radius- The search radius in kilometers.pageable- The pageable request.- Returns:
- A page of events.
-
findEventsForArtistFar
@Query(value="select e.* from events e inner join artist_events ae on e.id = ae.event_id inner join artists a on ae.artist_id = a.id inner join venues v on e.venue_id = v.id where a.id = :artistId and e.start_time >= :minimumStartTime and (v.geo_point is null or :point is null or st_distance(st_transform(v.geo_point, 3857), st_transform(:point, 3857)) > (:radius * 1000))", nativeQuery=true) org.springframework.data.domain.Page<Event> findEventsForArtistFar(UUID artistId, Instant minimumStartTime, org.locationtech.jts.geom.Point point, Double radius, org.springframework.data.domain.Pageable pageable) Finds events for an artist far from a geographic point.- Parameters:
artistId- The ID of the artist.minimumStartTime- The minimum start time for events.point- The geographic point.radius- The search radius in kilometers.pageable- The pageable request.- Returns:
- A page of events.
-
findEventsForArtistOrderByStartTime
@Query("select e from Event e inner join e.artists a where a.id = :artistId and e.startTime >= :minimumStartTime order by e.startTime asc") org.springframework.data.domain.Page<Event> findEventsForArtistOrderByStartTime(UUID artistId, Instant minimumStartTime, org.springframework.data.domain.Pageable pageable) Finds events for an artist, ordered by start time.- Parameters:
artistId- The ID of the artist.minimumStartTime- The minimum start time for events.pageable- The pageable request.- Returns:
- A page of events.
-
findEventsForCity
@Query("select e from Event e inner join e.venue v where v.city.id = :cityId and e.startTime >= :minimumStartTime and size(e.artists) != 0") org.springframework.data.domain.Page<Event> findEventsForCity(UUID cityId, Instant minimumStartTime, org.springframework.data.domain.Pageable pageable) Finds events for a city.- Parameters:
cityId- The ID of the city.minimumStartTime- The minimum start time for events.pageable- The pageable request.- Returns:
- A page of events.
-
findByNameAndVenue
@Query(value="select * from events where name ilike :name and venue_id = :venueId", nativeQuery=true) List<Event> findByNameAndVenue(String name, UUID venueId) Finds events by name and venue.- Parameters:
name- The name of the event.venueId- The ID of the venue.- Returns:
- A list of events.
-
findByNameAndVenueAndStartTimeBetween
@Query(value="select * from events where name ilike :name and venue_id = :venueId and start_time >= :min and start_time <= :max ", nativeQuery=true) List<Event> findByNameAndVenueAndStartTimeBetween(String name, UUID venueId, Instant min, Instant max) Finds events by name, venue, and start time between two timestamps.- Parameters:
name- The name of the event.venueId- The ID of the venue.min- The minimum start time.max- The maximum start time.- Returns:
- A list of events.
-
findByArtistAndVenueAndStartTime
@Query(value="select e.* from events e join artist_events ae on e.id = ae.event_id where ae.artist_id = :artistId and e.venue_id = :venueId and e.start_time >= :min and e.start_time <= :max ", nativeQuery=true) List<Event> findByArtistAndVenueAndStartTime(UUID artistId, UUID venueId, Instant min, Instant max) Finds events by artist, venue, and start time between two timestamps.- Parameters:
artistId- The ID of the artist.venueId- The ID of the venue.min- The minimum start time.max- The maximum start time.- Returns:
- A list of events.
-
findByBandsInTownId
Finds an event by its BandsInTown ID.- Parameters:
bitId- The BandsInTown ID.- Returns:
- The event.
-
findByPollstarId
Finds an event by its Pollstar ID.- Parameters:
pollstarId- The Pollstar ID.- Returns:
- The event.
-
findByEventNameNativeAndDoorTimeGreaterThanEqual
@Query(value="select * from events where unaccent(name) ilike concat(\'%\', :name, \'%\') and door_time >= :doorTime order by similarity(name, :name) limit :limit", nativeQuery=true) List<Event> findByEventNameNativeAndDoorTimeGreaterThanEqual(String name, Instant doorTime, int limit) Finds events by name and door time greater than or equal to a certain time.- Parameters:
name- The name of the event.doorTime- The minimum door time.limit- The maximum number of results to return.- Returns:
- A list of events.
-
findTopArtistsForEvent
@Query("select a from Event e join ArtistEvent ae on e = ae.event join Artist a on ae.artist = a where e.id = :eventId order by a.spotifyPopularity desc nulls last") org.springframework.data.domain.Page<Artist> findTopArtistsForEvent(UUID eventId, org.springframework.data.domain.Pageable pageable) Finds the top artists for an event.- Parameters:
eventId- The ID of the event.pageable- The pageable request.- Returns:
- A page of artists.
-
countByCityIdAfter
@Query("select count(e) from Event e join Venue v on e.venue = v join City c on v.city = c where c.id = :cityId and e.startTime >= :startTime ") Integer countByCityIdAfter(UUID cityId, Instant startTime) Counts the number of events in a city after a certain time.- Parameters:
cityId- The ID of the city.startTime- The minimum start time.- Returns:
- The number of events.
-
findEventsByVenueIdAndStartTimeAfterOrderByStartTimeAsc
org.springframework.data.domain.Page<Event> findEventsByVenueIdAndStartTimeAfterOrderByStartTimeAsc(UUID venueId, Instant startTime, org.springframework.data.domain.Pageable pageable) Finds events for a venue after a certain time, ordered by start time.- Parameters:
venueId- The ID of the venue.startTime- The minimum start time.pageable- The pageable request.- Returns:
- A page of events.
-
findEventsByVenueIdAndStartTimeBeforeOrderByStartTimeAsc
org.springframework.data.domain.Page<Event> findEventsByVenueIdAndStartTimeBeforeOrderByStartTimeAsc(UUID venueId, Instant startTime, org.springframework.data.domain.Pageable pageable) Finds events for a venue before a certain time, ordered by start time.- Parameters:
venueId- The ID of the venue.startTime- The maximum start time.pageable- The pageable request.- Returns:
- A page of events.
-
addEvent
@Modifying @Transactional @Query(value="insert into events (id, name, start_time, venue_id, created_at, updated_at) values (:id, :name, :startTime, :venueId, current_timestamp, current_timestamp) on conflict do nothing", nativeQuery=true) void addEvent(UUID id, String name, Instant startTime, UUID venueId) Adds a new event.- Parameters:
id- The ID of the event.name- The name of the event.startTime- The start time of the event.venueId- The ID of the venue.
-
findTopByOrderByCreatedAt
Event findTopByOrderByCreatedAt()Finds the most recently created event.- Returns:
- The event.
-
countByBandsInTownUpdatedAtBetween
Counts the number of events updated from BandsInTown between two timestamps.- Parameters:
start- The start timestamp.end- The end timestamp.- Returns:
- A completable future containing the number of events.
-
countByPollstarUpdatedAtBetween
Counts the number of events updated from Pollstar between two timestamps.- Parameters:
start- The start timestamp.end- The end timestamp.- Returns:
- A completable future containing the number of events.
-
countBySpotifyUpdatedAtBetween
Counts the number of events updated from Spotify between two timestamps.- Parameters:
start- The start timestamp.end- The end timestamp.- Returns:
- A completable future containing the number of events.
-
countByGoogleUpdatedAtBetween
Counts the number of events updated from Google between two timestamps.- Parameters:
start- The start timestamp.end- The end timestamp.- Returns:
- A completable future containing the number of events.
-
countByCreatedAtBetweenAndBandsInTownUpdatedAtNotNull
@Async CompletableFuture<Long> countByCreatedAtBetweenAndBandsInTownUpdatedAtNotNull(Instant start, Instant end) Counts the number of events 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 events.
-
countByCreatedAtBetweenAndPollstarUpdatedAtNotNull
@Async CompletableFuture<Long> countByCreatedAtBetweenAndPollstarUpdatedAtNotNull(Instant start, Instant end) Counts the number of events 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 events.
-
countByCreatedAtBetweenAndGoogleUpdatedAtNotNull
@Async CompletableFuture<Long> countByCreatedAtBetweenAndGoogleUpdatedAtNotNull(Instant start, Instant end) Counts the number of events created between two timestamps that have been updated from Google.- Parameters:
start- The start timestamp.end- The end timestamp.- Returns:
- A completable future containing the number of events.
-
countByCreatedAtBetweenAndSpotifyUpdatedAtNotNull
@Async CompletableFuture<Long> countByCreatedAtBetweenAndSpotifyUpdatedAtNotNull(Instant start, Instant end) Counts the number of events 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 events.
-
countByCreatedAtBeforeAndStartTimeAfter
@Async CompletableFuture<Long> countByCreatedAtBeforeAndStartTimeAfter(Instant before, Instant after) Counts the number of events created before a certain time that start after a certain time.- Parameters:
before- The creation timestamp to check before.after- The start timestamp to check after.- Returns:
- A completable future containing the number of events.
-
countByStartTimeAfter
Counts the number of events starting after a certain time.- Parameters:
after- The start timestamp to check after.- Returns:
- A completable future containing the number of events.
-
countByVenueIdAndStartTimeAfter
Counts the number of events for a venue after a certain time.- Parameters:
venueId- The ID of the venue.after- The start timestamp to check after.- Returns:
- The number of events.
-