Interface ActivityRepository

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

@Repository public interface ActivityRepository extends org.springframework.data.jpa.repository.JpaRepository<Activity,Integer>
Spring Data JPA repository for Activity entities.

Provides standard CRUD operations as well as custom query methods for retrieving activities by creator, sport, and date range.

Author:
SportTrack Team
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks whether an activity with the given identifier was created by the specified athlete.
    findActivitiesForChallengeRanking(List<Integer> athleteIds, Integer sportId, LocalDate startDate, LocalDate endDate)
    Finds activities matching the criteria for challenge ranking computation.
    Finds all activities created by any of the specified athletes, ordered by date and start time descending.
    Finds all activities created by a specific athlete, ordered by date and start time descending.
    Finds a single activity by its identifier and the identifier of the athlete who created it.

    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

    • findByCreatedBy_IdOrderByDateADescStartTimeDesc

      List<Activity> findByCreatedBy_IdOrderByDateADescStartTimeDesc(Integer athleteId)
      Finds all activities created by a specific athlete, ordered by date and start time descending.
      Parameters:
      athleteId - the unique identifier of the athlete who created the activities
      Returns:
      a list of matching activities, newest first
    • findByCreatedBy_IdInOrderByDateADescStartTimeDesc

      List<Activity> findByCreatedBy_IdInOrderByDateADescStartTimeDesc(List<Integer> athleteIds)
      Finds all activities created by any of the specified athletes, ordered by date and start time descending.
      Parameters:
      athleteIds - the list of athlete identifiers whose activities should be retrieved
      Returns:
      a list of matching activities, newest first
    • findActivitiesForChallengeRanking

      @Query("SELECT a\nFROM Activity a\nWHERE a.createdBy.id IN :athleteIds\n AND a.sportAndType.id = :sportId\n AND a.dateA BETWEEN :startDate AND :endDate\n") List<Activity> findActivitiesForChallengeRanking(@Param("athleteIds") List<Integer> athleteIds, @Param("sportId") Integer sportId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate)
      Finds activities matching the criteria for challenge ranking computation. Returns activities performed by the given athletes, for the specified sport, within the given date range.
      Parameters:
      athleteIds - the identifiers of the athletes whose activities should be considered
      sportId - the identifier of the sport to filter by
      startDate - the inclusive start date of the range
      endDate - the inclusive end date of the range
      Returns:
      a list of matching activities
    • findByIdAndCreatedBy_Id

      Optional<Activity> findByIdAndCreatedBy_Id(Integer id, Integer athleteId)
      Finds a single activity by its identifier and the identifier of the athlete who created it.
      Parameters:
      id - the activity identifier
      athleteId - the creator's identifier
      Returns:
      an Optional containing the activity if found, empty otherwise
    • existsByIdAndCreatedBy_Id

      boolean existsByIdAndCreatedBy_Id(Integer id, Integer athleteId)
      Checks whether an activity with the given identifier was created by the specified athlete.
      Parameters:
      id - the activity identifier
      athleteId - the creator's identifier
      Returns:
      true if such an activity exists, false otherwise