From 0e062f133707716faa6843f73164f415adf8d34e Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Tue, 30 Apr 2019 11:41:36 +0400 Subject: [PATCH] #70 fast fix --- src/main/java/ru/ulstu/ping/repository/PingRepository.java | 4 ++-- src/main/java/ru/ulstu/ping/service/PingService.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/ru/ulstu/ping/repository/PingRepository.java b/src/main/java/ru/ulstu/ping/repository/PingRepository.java index 8e69111..de79dd7 100644 --- a/src/main/java/ru/ulstu/ping/repository/PingRepository.java +++ b/src/main/java/ru/ulstu/ping/repository/PingRepository.java @@ -8,6 +8,6 @@ import ru.ulstu.ping.model.Ping; public interface PingRepository extends JpaRepository { - @Query("SELECT count(*) FROM Ping p WHERE (DAY(p.date) = :day) AND (MONTH(p.date) = :month) AND (p.conference = :conference)") - long countByConferenceAndDate(@Param("conference") Conference conference, @Param("day") Integer day, @Param("month") Integer month); + @Query("SELECT count(*) FROM Ping p WHERE (DAY(p.date) = :day) AND (MONTH(p.date) = :month) AND (YEAR(p.date) = :year) AND (p.conference = :conference)") + long countByConferenceAndDate(@Param("conference") Conference conference, @Param("day") Integer day, @Param("month") Integer month, @Param("year") Integer year); } diff --git a/src/main/java/ru/ulstu/ping/service/PingService.java b/src/main/java/ru/ulstu/ping/service/PingService.java index 3152e5a..f24ed9d 100644 --- a/src/main/java/ru/ulstu/ping/service/PingService.java +++ b/src/main/java/ru/ulstu/ping/service/PingService.java @@ -33,6 +33,7 @@ public class PingService { Calendar cal = Calendar.getInstance(); cal.setTime(yesterday); - return Math.toIntExact(pingRepository.countByConferenceAndDate(conference, cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1)); + return Math.toIntExact(pingRepository.countByConferenceAndDate(conference, cal.get(Calendar.DAY_OF_MONTH), + cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR))); } }