Skip to content

Commit

Permalink
fix 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Yasnodoom committed Sep 4, 2024
1 parent 4e2a5cd commit b36cc8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ List<Event> findByParams(@Param("annotation") String annotation,
select * from events e
where :annotation is null or lower(e.annotation) like lower(:annotation)
and e.state like 'PUBLISHED'
and :categories is null or e.category_id in :categories
and :paid is null or e.paid = :paid
and coalesce(:categories, null) is null or e.category_id in (:categories)
and coalesce(:paid, null) is null or e.paid = (:paid)
and e.event_date > current_timestamp
""", nativeQuery = true)
List<Event> findByParamsWithoutTimeRage(@Param("annotation") String annotation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ru.practicum.server.sevice;

import jakarta.validation.ValidationException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import ru.practicum.dto.logevent.LogEvent;
Expand All @@ -19,6 +20,13 @@ public LogEvent save(LogEvent data) {
}

public List<ViewStats> findByParams(LocalDateTime start, LocalDateTime end, List<String> uris, boolean unique) {
if (start == null || end == null) {
throw new ValidationException("date is null");
}
if (end.isAfter(start)) {
throw new ValidationException("end date is after start date");
}

if (unique) {
return repository.findByParamsUniqueIp(start, end, uris);
} else {
Expand Down

0 comments on commit b36cc8b

Please sign in to comment.