Package org.localify.repositories
Interface UserSeedRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<UserSeedArtist,,UUID> org.springframework.data.jpa.repository.JpaRepository<UserSeedArtist,,UUID> org.springframework.data.repository.ListCrudRepository<UserSeedArtist,,UUID> org.springframework.data.repository.ListPagingAndSortingRepository<UserSeedArtist,,UUID> org.springframework.data.repository.PagingAndSortingRepository<UserSeedArtist,,UUID> org.springframework.data.repository.query.QueryByExampleExecutor<UserSeedArtist>,org.springframework.data.repository.Repository<UserSeedArtist,UUID>
public interface UserSeedRepository
extends org.springframework.data.jpa.repository.JpaRepository<UserSeedArtist,UUID>
Repository for
UserSeedArtist entities.-
Method Summary
Modifier and TypeMethodDescriptionintCounts the number of discovered artists.countDiscoveredArtistsByTime(Instant start, Instant end) Counts the number of discovered artists between two timestamps.voidDeletes all non-blacklisted seed artists for a user.Finds the most recently created user seed artist.getByUserId(UUID userId) Gets a list of a user's seed artists.getByUserIdAndArtistId(UUID userId, UUID artistId) Gets a user's seed artist by user ID and artist ID.Gets a list of a user's non-blacklisted seed artists.Gets a list of a user's blacklisted seed artists.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
-
getByUserIdAndBlacklistedAtIsNull
Gets a list of a user's non-blacklisted seed artists.- Parameters:
userId- The ID of the user.- Returns:
- A list of user seed artists.
-
getByUserId
Gets a list of a user's seed artists.- Parameters:
userId- The ID of the user.- Returns:
- A list of user seed artists.
-
getByUserIdAndArtistId
Gets a user's seed artist by user ID and artist ID.- Parameters:
userId- The ID of the user.artistId- The ID of the artist.- Returns:
- An optional containing the user seed artist if found, otherwise empty.
-
getByUserIdAndBlacklistedAtNotNull
Gets a list of a user's blacklisted seed artists.- Parameters:
userId- The ID of the user.- Returns:
- A list of user seed artists.
-
deleteAllByUserIdAndBlacklistedAtIsNull
Deletes all non-blacklisted seed artists for a user.- Parameters:
userId- The ID of the user.
-
findTopByOrderByCreatedAt
UserSeedArtist findTopByOrderByCreatedAt()Finds the most recently created user seed artist.- Returns:
- The user seed artist.
-
countDiscoveredArtists
@Query(value="select count(distinct usa.user_id || \'-\' || usa.artist_id)\nfrom user_seed_artists usa\njoin user_recommendations ur\n on usa.user_id = ur.user_id\n and usa.created_at > ur.created_at\njoin user_artist_recommendations uar\n on ur.id = uar.user_rec_id\n and usa.artist_id = uar.artist_id\nwhere usa.blacklisted_at is null;\n", nativeQuery=true) int countDiscoveredArtists()Counts the number of discovered artists.- Returns:
- The number of discovered artists.
-
countDiscoveredArtistsByTime
@Async @Query(value="select count(distinct usa.user_id || \'-\' || usa.artist_id)\nfrom user_seed_artists usa\njoin user_recommendations ur\n on usa.user_id = ur.user_id\n and usa.created_at > ur.created_at\njoin user_artist_recommendations uar\n on ur.id = uar.user_rec_id\n and usa.artist_id = uar.artist_id\nwhere usa.blacklisted_at is null\nand usa.created_at >= :start and usa.created_at <= :end\n", nativeQuery=true) CompletableFuture<Long> countDiscoveredArtistsByTime(Instant start, Instant end) Counts the number of discovered artists between two timestamps.- Parameters:
start- The start timestamp.end- The end timestamp.- Returns:
- A completable future containing the number of discovered artists.
-