diff options
author | stuebinm | 2022-08-27 01:45:12 +0200 |
---|---|---|
committer | stuebinm | 2022-08-27 01:45:12 +0200 |
commit | a4045a5b0a898042cd78eba9b22550c965a1bbd9 (patch) | |
tree | 337277b15c7fba9ea857cdd388ff1b2c84d9101b /lib/GTFS.hs | |
parent | 6fa510d35f0ca8738df7274bf6f02ad75a987f60 (diff) |
controlroom: lots of pretty little knobs
(also some database schema changes, for good measure)
Diffstat (limited to '')
-rw-r--r-- | lib/GTFS.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/GTFS.hs b/lib/GTFS.hs index 9259649..bfb1c49 100644 --- a/lib/GTFS.hs +++ b/lib/GTFS.hs @@ -51,6 +51,7 @@ import Web.Internal.FormUrlEncoded (FromForm (..)) import Web.Internal.HttpApiData (FromHttpApiData (..)) -- import Data.Aeson.Generic (Options(fieldLabelModifier), deriveJSON, defaultOptions) import Control.Lens +import Control.Monad.IO.Class (MonadIO (liftIO)) import Data.Char (toLower) import Data.Foldable (Foldable (fold)) import Data.Map (Map) @@ -459,3 +460,12 @@ tripsAtStation GTFS{..} at = fmap stopTrip stops tripsOnDay :: GTFS -> Day -> Map TripID (Trip Deep Deep) tripsOnDay gtfs today = foldMap (tripsOfService gtfs) (servicesOnDay gtfs today) + +runsOnDay :: GTFS -> TripID -> Day -> Bool +runsOnDay gtfs trip day = not . null . M.filter same $ tripsOnDay gtfs day + where same Trip{..} = tripTripID == trip + +runsToday :: MonadIO m => GTFS -> TripID -> m Bool +runsToday gtfs trip = do + today <- liftIO getCurrentTime <&> utctDay + pure (runsOnDay gtfs trip today) |