diff options
author | stuebinm | 2024-05-15 01:12:09 +0200 |
---|---|---|
committer | stuebinm | 2024-05-15 01:12:09 +0200 |
commit | 0c9b3a6dba6850ce526d1d397f35aa6ad76beb50 (patch) | |
tree | f7b307548904ed0c0bb1459b9d09da63ed0a4243 /lib/Persist.hs | |
parent | 59670bdb6f0a3bba898274eadf47707e93bea195 (diff) |
Server.Ingest: new handling of unassigned trackers
now takes all potential stops along each trip into account when guessing
tickets; also checks if a ticket is still likely in case the tracker
switched its direction. This should solve many cases where a tracker is
accidentally turned off or falls asleep halfway before the last station
of one trip, then wakes up in the middle of the next.
Diffstat (limited to 'lib/Persist.hs')
-rw-r--r-- | lib/Persist.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Persist.hs b/lib/Persist.hs index 46e5ef4..e268455 100644 --- a/lib/Persist.hs +++ b/lib/Persist.hs @@ -142,6 +142,8 @@ TrainPing json sql=tt_trip_ping token TrackerId geopos Geopos timestamp UTCTime + sequence Double + ticket TicketId deriving Show Generic Eq -- status of a train somewhen in time (may be in the future), @@ -177,6 +179,8 @@ instance ToSchema TrainAnchor where instance ToSchema Announcement where declareNamedSchema = genericDeclareNamedSchema (GTFS.swaggerOptions "announcement") +type InSql a = ReaderT SqlBackend (LoggingT (ResourceT IO)) a + runSqlWithoutLog :: MonadIO m => Pool SqlBackend -> ReaderT SqlBackend (NoLoggingT (ResourceT IO)) a @@ -188,7 +192,7 @@ runSqlWithoutLog pool = liftIO . flip runSqlPersistMPool pool -- no better way than to nest logger monads … runSql :: (MonadLogger m, MonadIO m, MonadReader LoggingConfig m) => Pool SqlBackend - -> ReaderT SqlBackend (LoggingT (ResourceT IO)) a + -> InSql a -> m a runSql pool x = do conf <- ask |