Interface UserRepository

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

public interface UserRepository extends org.springframework.data.jpa.repository.JpaRepository<User,UUID>
Repository for User entities.
  • Method Details

    • findBySpotifyId

      Optional<User> findBySpotifyId(String spotifyId)
      Finds a user by their Spotify ID.
      Parameters:
      spotifyId - The Spotify ID.
      Returns:
      An optional containing the user if found, otherwise empty.
    • findByGoogleId

      Optional<User> findByGoogleId(String googleId)
      Finds a user by their Google ID.
      Parameters:
      googleId - The Google ID.
      Returns:
      An optional containing the user if found, otherwise empty.
    • findByAppleId

      Optional<User> findByAppleId(String appleId)
      Finds a user by their Apple Music ID.
      Parameters:
      appleId - The Apple Music ID.
      Returns:
      An optional containing the user if found, otherwise empty.
    • findById

      Optional<User> findById(UUID id)
      Finds a user by their ID.
      Specified by:
      findById in interface org.springframework.data.repository.CrudRepository<User,UUID>
      Parameters:
      id - The ID of the user.
      Returns:
      An optional containing the user if found, otherwise empty.
    • isUserGuest

      @Query("select u.isGuest from User u where u.id = :userId") Boolean isUserGuest(UUID userId)
      Checks if a user is a guest.
      Parameters:
      userId - The ID of the user.
      Returns:
      true if the user is a guest, false otherwise.
    • findByUserEmail

      @Query("select u from User u where u.userEmail ilike :email") Optional<User> findByUserEmail(String email)
      Finds a user by their email address.
      Parameters:
      email - The email address.
      Returns:
      An optional containing the user if found, otherwise empty.
    • countByIsGuestFalseAndCreatedAtBetween

      @Async CompletableFuture<Long> countByIsGuestFalseAndCreatedAtBetween(Instant start, Instant end)
      Counts the number of non-guest users created between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of users.
    • countByIsGuestTrueAndCreatedAtBetween

      @Async CompletableFuture<Long> countByIsGuestTrueAndCreatedAtBetween(Instant start, Instant end)
      Counts the number of guest users created between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of users.
    • countByUpdatedAtBetween

      @Async CompletableFuture<Long> countByUpdatedAtBetween(Instant start, Instant end)
      Counts the number of users updated between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of users.
    • countBySpotifyIdNotNull

      @Async CompletableFuture<Integer> countBySpotifyIdNotNull()
      Counts the number of users with a Spotify ID.
      Returns:
      A completable future containing the number of users.
    • countByUserEmailNotNull

      @Async CompletableFuture<Integer> countByUserEmailNotNull()
      Counts the number of users with an email address.
      Returns:
      A completable future containing the number of users.
    • countByUserEmailNotNullAndSpotifyIdNotNull

      Integer countByUserEmailNotNullAndSpotifyIdNotNull()
      Counts the number of users with both an email address and a Spotify ID.
      Returns:
      The number of users.
    • countByCreatedAtBefore

      @Async CompletableFuture<Integer> countByCreatedAtBefore(Instant createdAt)
      Counts the number of users created before a certain time.
      Parameters:
      createdAt - The timestamp to check against.
      Returns:
      A completable future containing the number of users.
    • findTopByOrderByCreatedAt

      User findTopByOrderByCreatedAt()
      Finds the most recently created user.
      Returns:
      The user.
    • countByEmailOptInTrue

      @Async CompletableFuture<Integer> countByEmailOptInTrue()
      Counts the number of users who have opted in to emails.
      Returns:
      A completable future containing the number of users.
    • countByEmailVerifiedTrue

      @Async CompletableFuture<Integer> countByEmailVerifiedTrue()
      Counts the number of users with a verified email address.
      Returns:
      A completable future containing the number of users.
    • getAllOrderByAdminThenNameFiltered

      @Query("select u from User u\nwhere (\'ADMIN\' in :filters and u.isAdmin = true) or\n (\'TEAM_MEMBER\' in :filters and u.isTeamMember = true) or\n (\'GUEST\' in :filters and u.isGuest = true) or\n (\'DISABLED\' in :filters and u.isDisabled = true)\norder by u.isAdmin desc, u.name\n") org.springframework.data.domain.Page<User> getAllOrderByAdminThenNameFiltered(org.springframework.data.domain.Pageable pageable, List<String> filters)
      Gets a page of users, filtered by role and ordered by admin status and name.
      Parameters:
      pageable - The pageable request.
      filters - The list of roles to filter by.
      Returns:
      A page of users.
    • getAllOrderByAdminThenName

      @Query("select u from User u\norder by u.isAdmin desc, u.name\n") org.springframework.data.domain.Page<User> getAllOrderByAdminThenName(org.springframework.data.domain.Pageable pageable)
      Gets a page of all users, ordered by admin status and name.
      Parameters:
      pageable - The pageable request.
      Returns:
      A page of users.
    • getUserSeeds

      @Query("select us.artist.id from UserSeedArtist us where us.user.id = :userId and us.blacklistedAt is null ") List<UUID> getUserSeeds(UUID userId)
      Gets the seed artist IDs for a user.
      Parameters:
      userId - The ID of the user.
      Returns:
      A list of seed artist IDs.
    • findByNameNative

      @Query(value="select * from users where name ilike concat(\'%\', :name, \'%\') limit :limit", nativeQuery=true) List<User> findByNameNative(String name, int limit)
      Finds users by name using a native query.
      Parameters:
      name - The name to search for.
      limit - The maximum number of results to return.
      Returns:
      A list of users.
    • findIdsByNameNative

      @Query(value="select id from users where name ilike concat(\'%\', :name, \'%\') limit :limit", nativeQuery=true) List<UUID> findIdsByNameNative(String name, int limit)
      Finds user IDs by name using a native query.
      Parameters:
      name - The name to search for.
      limit - The maximum number of results to return.
      Returns:
      A list of user IDs.
    • findAllByEmailOptInTrueAndUserEmailNotNull

      List<User> findAllByEmailOptInTrueAndUserEmailNotNull()
      Finds all users who have opted in to emails and have an email address.
      Returns:
      A list of users.