Package org.localify.repositories
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 Summary
Modifier and TypeMethodDescriptioncountActiveUsersBetween(Instant after, Instant before) Counts the number of active users between two timestamps.countByCreatedAtBetween(Instant after, Instant before) Counts the number of user-city relationships created between two timestamps.countReturningUsersBetween(Instant after, Instant before) Counts the number of returning users between two timestamps.Finds all user-city relationships where the playlist is not null and the user is not deleted.findByKeyUserId(UUID userId) Finds all user-city relationships for a user, ordered by selected time.findByKeyUserId(UUID userId, org.springframework.data.domain.Pageable req) Finds a page of user-city relationships for a user, ordered by selected time.findByKeyUserIdAndKeyCityId(UUID userId, UUID cityId) Finds a user-city relationship by user ID and city ID.findByUserAndCity(User user, City city) Finds a user-city relationship by user and city.findByUserIdAndCityId(UUID userId, UUID cityId) Finds a user-city relationship by user ID and city ID.findByUserIdOrderByCreatedAtDesc(UUID userId) Finds all user-city relationships for a user, ordered by creation date.Finds the most recently selected user-city relationship for a user.Finds the most recently created user-city relationship.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
-
findByUserAndCity
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
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
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
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
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
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
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.
-