diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2026-07-20 11:10:21 +0200 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2026-07-20 11:10:21 +0200 |
| commit | 9f52bec00561d7d481b79a38fa02586626b4b5cd (patch) | |
| tree | 405566b391ce43743aa997a213d06371658fdcb7 /src/Index.hs | |
| parent | 72379334b9efa362e7083963b75bb6e69530298d (diff) | |
Prev/next buttons on calendar-day
Thanks jreicher for suggesting!
Diffstat (limited to 'src/Index.hs')
| -rw-r--r-- | src/Index.hs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Index.hs b/src/Index.hs index 4b852bf..eedd1cd 100644 --- a/src/Index.hs +++ b/src/Index.hs @@ -466,24 +466,27 @@ indexCalendar (Index _ mp _) chan = do else coAll (scan IGV.! i) - coAll (scan IGV.! (i - 1)) | i <- [0 .. IGV.length scan - 1]]) -indexGetEventsDay :: Index -> Channel -> CountKind -> Day -> IO [(HMS, EventID, Event)] +-- | Returns the first and last day of this channel's logs, as well as the actual events on the requested day +indexGetEventsDay :: Index -> Channel -> CountKind -> Day -> IO ((Day, Day), [(HMS, EventID, Event)]) indexGetEventsDay index@(Index _ mp _) chan kind day = do ci <- readIORef (mp Map.! chan) + let firstlast = (ciStartDay ci, ciEndDay ci) let ymd = dayToYMD day if day < ciStartDay ci || day > ciEndDay ci - then return [] + then return (firstlast, []) else loadDay index chan ymd <&> \case Just (bs, _lineStarts) -> let events = parseLog bs - in case kind of - CKAll -> - [(hms, genEventID (YMDHMS ymd hms) off, ev) - | ((hms, ev), off) <- zip events [0..]] - CKCompressed -> - [(hms, genEventID (YMDHMS ymd hms) off, ev) - | ((hms, off), ev) <- compressEvents [((hms, off), ev) - | ((hms, ev), off) <- zip events [0..]]] - Nothing -> [] -- if the file doesn't exist, there ain't no events + events' = case kind of + CKAll -> + [(hms, genEventID (YMDHMS ymd hms) off, ev) + | ((hms, ev), off) <- zip events [0..]] + CKCompressed -> + [(hms, genEventID (YMDHMS ymd hms) off, ev) + | ((hms, off), ev) <- compressEvents [((hms, off), ev) + | ((hms, ev), off) <- zip events [0..]]] + in (firstlast, events') + Nothing -> (firstlast, []) -- if the file doesn't exist, there ain't no events -- utilities |
