reorder imports

This commit is contained in:
Daniel Barlow 2024-11-10 22:17:18 +00:00
parent 7bc7f9e89f
commit 1fd0435da6
4 changed files with 25 additions and 26 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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]