This commit is contained in:
Nightblade73 2019-04-30 11:41:36 +04:00
parent 9edcf35338
commit 0e062f1337
2 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,6 @@ import ru.ulstu.ping.model.Ping;
public interface PingRepository extends JpaRepository<Ping, Integer> {
@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);
}

View File

@ -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)));
}
}