2020import ru .practicum .statistics .dto .ViewStats ;
2121
2222import java .time .LocalDateTime ;
23- import java .time .format .DateTimeFormatter ;
2423import java .util .*;
2524import java .util .stream .Collectors ;
2625
@@ -31,15 +30,19 @@ public class PublicEventServiceImpl implements PublicEventService {
3130 private final EventRepository eventRepository ;
3231 private final StatsClient statsClient ;
3332
34- private static final DateTimeFormatter FORMATTER = DateTimeFormatter .ofPattern ("yyyy-MM-dd HH:mm:ss" );
35- private static final LocalDateTime STATS_START = LocalDateTime .of (2000 , 1 , 1 , 0 , 0 , 0 );
36-
3733 @ Override
3834 @ Transactional (readOnly = true )
3935 public List <EventShortDto > getEvents (String text , List <Long > categories , Boolean paid ,
4036 LocalDateTime rangeStart , LocalDateTime rangeEnd ,
4137 Boolean onlyAvailable , SortType sort ,
4238 int from , int size , HttpServletRequest request ) {
39+ if (size <= 0 ) {
40+ size = 10 ;
41+ }
42+ if (from < 0 ) {
43+ from = 0 ;
44+ }
45+
4346 sendHit (request );
4447
4548 LocalDateTime now = LocalDateTime .now ();
@@ -119,7 +122,7 @@ private Map<Long, Long> getViewsMap(List<Event> events) {
119122 .collect (Collectors .toList ());
120123 try {
121124 LocalDateTime start = LocalDateTime .of (2000 , 1 , 1 , 0 , 0 , 0 );
122- LocalDateTime end = LocalDateTime .now ().plusSeconds ( 10 );
125+ LocalDateTime end = LocalDateTime .now ().plusMinutes ( 5 );
123126 List <ViewStats > stats = statsClient .getStats (start , end , uris , false );
124127 return stats .stream ()
125128 .collect (Collectors .toMap (
0 commit comments