Don't show future entries on /today endpoint

This commit is contained in:
Marcel Schwarz 2020-06-14 16:11:13 +02:00
parent f9ce4d4db8
commit ff1afd7c32
2 changed files with 8 additions and 2 deletions

View File

@ -45,7 +45,11 @@ public interface RecordRepository extends PagingAndSortingRepository<TimeRecord,
Pageable pageable
);
@Query("SELECT record from TimeRecord record where record.account.user.username = :#{principal} AND record.enddate > current_date")
@Query("SELECT record from TimeRecord record " +
"where record.account.user.username = :#{principal} " +
"AND record.enddate > current_date " +
"AND record.enddate < current_date+1"
)
Page<TimeRecord> today(Pageable pageable);
@RestResource(rel = "openEntries", path = "openEntries")

View File

@ -34,6 +34,8 @@ INSERT INTO time_record (id, enddate, startdate, `type`, account_id) VALUES
(6, '2020-05-30 23:00:00', '2020-05-30 22:00:00', 1, 1),
(7, '2020-05-31 01:00:00', '2020-05-31 00:00:00', 1, 1),
(8, '2020-05-31 04:00:00', '2020-05-31 02:00:00', 1, 1),
(9, '2020-05-31 16:00:00', '2020-05-31 12:00:00', 1, 1);
(9, '2020-05-31 16:00:00', '2020-05-31 12:00:00', 1, 1),
(10, '2020-06-14 16:00:00', '2020-06-14 12:00:00', 1, 1),
(11, '2020-06-15 16:00:00', '2020-06-15 12:00:00', 1, 1);
SET FOREIGN_KEY_CHECKS=1;