Interface UserCityRepository

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

public interface UserCityRepository extends org.springframework.data.jpa.repository.JpaRepository<UserCity,UserCity.Key>
Repository for UserCity entities.
  • Method Details

    • findByUserAndCity

      Optional<UserCity> findByUserAndCity(User user, City city)
      Finds a user-city relationship by user and city.
      Parameters:
      user - The user.
      city - The city.
      Returns:
      An optional containing the user-city relationship if found, otherwise empty.
    • findByUserIdAndCityId

      Optional<UserCity> findByUserIdAndCityId(UUID userId, UUID cityId)
      Finds a user-city relationship by user ID and city ID.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      Returns:
      An optional containing the user-city relationship if found, otherwise empty.
    • findByKeyUserId

      @Query("select uc from UserCity uc where uc.key.userId = :userId order by uc.selectedAt desc") List<UserCity> findByKeyUserId(UUID userId)
      Finds all user-city relationships for a user, ordered by selected time.
      Parameters:
      userId - The ID of the user.
      Returns:
      A list of user-city relationships.
    • findByKeyUserId

      @Query("select uc from UserCity uc where uc.key.userId = :userId order by uc.selectedAt desc") List<UserCity> findByKeyUserId(UUID userId, org.springframework.data.domain.Pageable req)
      Finds a page of user-city relationships for a user, ordered by selected time.
      Parameters:
      userId - The ID of the user.
      req - The pageable request.
      Returns:
      A list of user-city relationships.
    • findByKeyUserIdAndKeyCityId

      Optional<UserCity> findByKeyUserIdAndKeyCityId(UUID userId, UUID cityId)
      Finds a user-city relationship by user ID and city ID.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      Returns:
      An optional containing the user-city relationship if found, otherwise empty.
    • countByCreatedAtBetween

      @Async CompletableFuture<Long> countByCreatedAtBetween(Instant after, Instant before)
      Counts the number of user-city relationships created between two timestamps.
      Parameters:
      after - The start timestamp.
      before - The end timestamp.
      Returns:
      A completable future containing the number of relationships.
    • countActiveUsersBetween

      @Async @Query("select count(distinct us.user)\nfrom UserCity us join Playlist p on us.playlist.id = p.id\nwhere p.createdAt >= :after and p.createdAt <= :before\n") CompletableFuture<Integer> countActiveUsersBetween(Instant after, Instant before)
      Counts the number of active users between two timestamps.
      Parameters:
      after - The start timestamp.
      before - The end timestamp.
      Returns:
      A completable future containing the number of active users.
    • countReturningUsersBetween

      @Async @Query("select count(distinct us.user)\nfrom UserCity us join Playlist p on us.playlist.id = p.id\njoin User u on us.user.id = u.id\nwhere (p.createdAt >= :after and p.createdAt <= :before)\nand u.createdAt <= :after\n") CompletableFuture<Integer> countReturningUsersBetween(Instant after, Instant before)
      Counts the number of returning users between two timestamps.
      Parameters:
      after - The start timestamp.
      before - The end timestamp.
      Returns:
      A completable future containing the number of returning users.
    • findAllByPlaylistNotNullAndUserDeletedAtNull

      List<UserCity> findAllByPlaylistNotNullAndUserDeletedAtNull()
      Finds all user-city relationships where the playlist is not null and the user is not deleted.
      Returns:
      A list of user-city relationships.
    • findByUserIdOrderByCreatedAtDesc

      List<UserCity> findByUserIdOrderByCreatedAtDesc(UUID userId)
      Finds all user-city relationships for a user, ordered by creation date.
      Parameters:
      userId - The ID of the user.
      Returns:
      A list of user-city relationships.
    • findFirstByUserIdOrderBySelectedAtDesc

      Optional<UserCity> findFirstByUserIdOrderBySelectedAtDesc(UUID userId)
      Finds the most recently selected user-city relationship for a user.
      Parameters:
      userId - The ID of the user.
      Returns:
      An optional containing the user-city relationship if found, otherwise empty.
    • findTopByOrderByCreatedAt

      UserCity findTopByOrderByCreatedAt()
      Finds the most recently created user-city relationship.
      Returns:
      The user-city relationship.