diff --git a/app/Main.hs b/app/Main.hs index 4f7cc8a..1787262 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -11,9 +11,9 @@ import Control.Monad.Trans.Resource (runResourceT) import Data.ByteString.Lazy as BS import Data.List as List import Data.Text as T -import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds) import Data.Time.Clock (nominalDiffTimeToSeconds) -import Database.Persist.Postgresql (ConnectionPool, ConnectionString, SqlBackend, runMigration, runSqlPool, getPgInterval, withPostgresqlPool) +import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds) +import Database.Persist.Postgresql (ConnectionPool, ConnectionString, SqlBackend, getPgInterval, runMigration, runSqlPool, withPostgresqlPool) import Debug.Trace (traceShow) import Session import Store @@ -58,8 +58,8 @@ instance YesodPersist Souplesse where getCalendarR :: Handler Html getCalendarR = do - let fTime = T.pack . show . floor . utcTimeToPOSIXSeconds - fDur = T.pack . show . ceiling . nominalDiffTimeToSeconds . getPgInterval + let fTime = T.pack . show . floor . utcTimeToPOSIXSeconds + fDur = T.pack . show . ceiling . nominalDiffTimeToSeconds . getPgInterval (formWidget, _) <- generateFormPost uploadForm sessions' <- runDB Session.recents defaultLayout diff --git a/lib/Point.hs b/lib/Point.hs index e573b8f..39e6488 100644 --- a/lib/Point.hs +++ b/lib/Point.hs @@ -19,12 +19,12 @@ import Data.Maybe import Data.Text qualified import Data.Text.Lazy as T import Data.Time +import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds) import Data.Time.ISO8601 qualified import Debug.Trace (trace, traceShow) import Text.Read (readMaybe) import Text.XML import Text.XML.Cursor as Cursor -import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds) data Pos = Pos Double Double (Maybe Double) deriving (Show, Eq) diff --git a/lib/Session.hs b/lib/Session.hs index 1860307..2cfaa75 100644 --- a/lib/Session.hs +++ b/lib/Session.hs @@ -14,28 +14,26 @@ {-# LANGUAGE UndecidableInstances #-} module Session - ( Session(..) - , recents - , updateSessions - , migrateSession - ) where - -import Data.Text -import Text.RawString.QQ (r) -import Data.Time.Clock ( - UTCTime, + ( Session (..), + recents, + updateSessions, + migrateSession, ) +where -import Database.Persist --- import Database.Persist.Class -import Database.Persist.TH -import Database.Persist.Postgresql - ( SqlBackend, - PgInterval - ) import Control.Monad.IO.Class (MonadIO) import Control.Monad.Trans.Reader (ReaderT) - +import Data.Text +import Data.Time.Clock + ( UTCTime, + ) +import Database.Persist +import Database.Persist.Postgresql + ( PgInterval, + SqlBackend, + ) +import Database.Persist.TH +import Text.RawString.QQ (r) share [mkPersist sqlSettings, mkMigrate "migrateSession"] @@ -48,7 +46,8 @@ Session |] updateSessions :: Text -updateSessions = [r| +updateSessions = + [r| -- delete existing drafts as new data may extend one of them delete from session where draft; -- find all potential start points in the new data @@ -63,7 +62,7 @@ insert into session(start_time, duration, draft) (select time as start_time, mak where draft; |] -recents :: (MonadIO m) => ReaderT SqlBackend m [Session] +recents :: (MonadIO m) => ReaderT SqlBackend m [Session] recents = do s <- selectList [SessionDraft !=. True] [Desc SessionStartTime, LimitTo 10] return $ Prelude.map (\(Entity _ x) -> x) s diff --git a/lib/Track.hs b/lib/Track.hs index 8a60fd5..a0842fc 100644 --- a/lib/Track.hs +++ b/lib/Track.hs @@ -27,10 +27,10 @@ import Data.Text.Lazy as T import Data.Time import Data.Time.ISO8601 qualified import Debug.Trace (trace, traceShow) +import Point import Text.Read (readMaybe) import Text.XML import Text.XML.Cursor as Cursor -import Point -- TODO do we even need this type? type Track = [Point]