Interface UserRecentArtistViewRepository

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

@Repository public interface UserRecentArtistViewRepository extends org.springframework.data.jpa.repository.JpaRepository<UserRecentArtistView,UserRecentArtistView.Key>
Repository for UserRecentArtistView entities.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addArtistView(UUID userId, UUID artistId)
    Adds a new artist view for a user.
    Counts the number of user recent artist views created between two timestamps.
    void
    Deletes all recent artist views for a user.
    findByUserIdAndArtistId(UUID userId, UUID artistId)
    Finds a user's recent artist view by user ID and artist ID.
    Finds the most recently created user recent artist view.
    getByUserIdOrderByUpdatedAtDesc(UUID userId, org.springframework.data.domain.Pageable pageable)
    Gets a list of a user's recent artist views, ordered by last updated time.

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • getByUserIdOrderByUpdatedAtDesc

      @Async CompletableFuture<List<UserRecentArtistView>> getByUserIdOrderByUpdatedAtDesc(UUID userId, org.springframework.data.domain.Pageable pageable)
      Gets a list of a user's recent artist views, ordered by last updated time.
      Parameters:
      userId - The ID of the user.
      pageable - The pageable request.
      Returns:
      A completable future containing a list of user recent artist views.
    • findByUserIdAndArtistId

      Optional<UserRecentArtistView> findByUserIdAndArtistId(UUID userId, UUID artistId)
      Finds a user's recent artist view 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 recent artist view if found, otherwise empty.
    • deleteAllByUserId

      void deleteAllByUserId(UUID userId)
      Deletes all recent artist views for a user.
      Parameters:
      userId - The ID of the user.
    • addArtistView

      @Modifying @Transactional @Query(value="insert into user_recent_artist_views (user_id, artist_id, created_at, updated_at) values (:userId, :artistId, current_timestamp, current_timestamp) on conflict do nothing", nativeQuery=true) void addArtistView(UUID userId, UUID artistId)
      Adds a new artist view for a user.
      Parameters:
      userId - The ID of the user.
      artistId - The ID of the artist.
    • findTopByOrderByCreatedAt

      UserRecentArtistView findTopByOrderByCreatedAt()
      Finds the most recently created user recent artist view.
      Returns:
      The user recent artist view.
    • countByCreatedAtBetween

      @Async CompletableFuture<Long> countByCreatedAtBetween(Instant start, Instant end)
      Counts the number of user recent artist views created between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of views.