Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface ActivityRepository extends JpaRepository<Activity, Long> {
boolean existsByAuthor(User principal);

@EntityGraph(attributePaths = {"participants", "author"})
@Query("SELECT a FROM Activity a WHERE a.isDeleted = false "
+ "AND a.localDateTime > current_timestamp")
Optional<Activity> findById(Long id);

@Query("SELECT a FROM Activity a JOIN a.author author "
+ "WHERE a.isDeleted = false AND a.localDateTime > current_timestamp "
+ "AND author.email = :email")
@EntityGraph(attributePaths = {"participants", "author"})
@Query("SELECT a FROM Activity a WHERE a.isDeleted = false "
+ "AND a.localDateTime > current_timestamp")
Page<Activity> findByAuthorEmail(Pageable pageable, String email);
Page<Activity> findByAuthorEmail(Pageable pageable, @Param("email") String email);

@Query("SELECT a FROM Activity a JOIN a.participants p "
+ "WHERE a.isDeleted = false AND a.localDateTime > current_timestamp "
+ "AND p.email = :email")
@EntityGraph(attributePaths = {"participants", "author"})
@Query("SELECT a FROM Activity a WHERE a.isDeleted = false "
+ "AND a.localDateTime > current_timestamp")
Page<Activity> findByParticipantsEmail(Pageable pageable, String name);
Page<Activity> findByParticipantsEmail(Pageable pageable, @Param("email") String email);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public Page<ActivityDto> getAll(Pageable pageable) {

@Override
public ActivityDto getById(Long id) {

return activityMapper.toDto(activityRepository
.findById(id)
.orElseThrow(
Expand Down