reorder imports
This commit is contained in:
parent
7bc7f9e89f
commit
1fd0435da6
@ -11,9 +11,9 @@ import Control.Monad.Trans.Resource (runResourceT)
|
|||||||
import Data.ByteString.Lazy as BS
|
import Data.ByteString.Lazy as BS
|
||||||
import Data.List as List
|
import Data.List as List
|
||||||
import Data.Text as T
|
import Data.Text as T
|
||||||
import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds)
|
|
||||||
import Data.Time.Clock (nominalDiffTimeToSeconds)
|
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 Debug.Trace (traceShow)
|
||||||
import Session
|
import Session
|
||||||
import Store
|
import Store
|
||||||
@ -58,8 +58,8 @@ instance YesodPersist Souplesse where
|
|||||||
|
|
||||||
getCalendarR :: Handler Html
|
getCalendarR :: Handler Html
|
||||||
getCalendarR = do
|
getCalendarR = do
|
||||||
let fTime = T.pack . show . floor . utcTimeToPOSIXSeconds
|
let fTime = T.pack . show . floor . utcTimeToPOSIXSeconds
|
||||||
fDur = T.pack . show . ceiling . nominalDiffTimeToSeconds . getPgInterval
|
fDur = T.pack . show . ceiling . nominalDiffTimeToSeconds . getPgInterval
|
||||||
(formWidget, _) <- generateFormPost uploadForm
|
(formWidget, _) <- generateFormPost uploadForm
|
||||||
sessions' <- runDB Session.recents
|
sessions' <- runDB Session.recents
|
||||||
defaultLayout
|
defaultLayout
|
||||||
|
@ -19,12 +19,12 @@ import Data.Maybe
|
|||||||
import Data.Text qualified
|
import Data.Text qualified
|
||||||
import Data.Text.Lazy as T
|
import Data.Text.Lazy as T
|
||||||
import Data.Time
|
import Data.Time
|
||||||
|
import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds)
|
||||||
import Data.Time.ISO8601 qualified
|
import Data.Time.ISO8601 qualified
|
||||||
import Debug.Trace (trace, traceShow)
|
import Debug.Trace (trace, traceShow)
|
||||||
import Text.Read (readMaybe)
|
import Text.Read (readMaybe)
|
||||||
import Text.XML
|
import Text.XML
|
||||||
import Text.XML.Cursor as Cursor
|
import Text.XML.Cursor as Cursor
|
||||||
import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds)
|
|
||||||
|
|
||||||
data Pos = Pos Double Double (Maybe Double) deriving (Show, Eq)
|
data Pos = Pos Double Double (Maybe Double) deriving (Show, Eq)
|
||||||
|
|
||||||
|
@ -14,28 +14,26 @@
|
|||||||
{-# LANGUAGE UndecidableInstances #-}
|
{-# LANGUAGE UndecidableInstances #-}
|
||||||
|
|
||||||
module Session
|
module Session
|
||||||
( Session(..)
|
( Session (..),
|
||||||
, recents
|
recents,
|
||||||
, updateSessions
|
updateSessions,
|
||||||
, migrateSession
|
migrateSession,
|
||||||
) where
|
|
||||||
|
|
||||||
import Data.Text
|
|
||||||
import Text.RawString.QQ (r)
|
|
||||||
import Data.Time.Clock (
|
|
||||||
UTCTime,
|
|
||||||
)
|
)
|
||||||
|
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.IO.Class (MonadIO)
|
||||||
import Control.Monad.Trans.Reader (ReaderT)
|
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
|
share
|
||||||
[mkPersist sqlSettings, mkMigrate "migrateSession"]
|
[mkPersist sqlSettings, mkMigrate "migrateSession"]
|
||||||
@ -48,7 +46,8 @@ Session
|
|||||||
|]
|
|]
|
||||||
|
|
||||||
updateSessions :: Text
|
updateSessions :: Text
|
||||||
updateSessions = [r|
|
updateSessions =
|
||||||
|
[r|
|
||||||
-- delete existing drafts as new data may extend one of them
|
-- delete existing drafts as new data may extend one of them
|
||||||
delete from session where draft;
|
delete from session where draft;
|
||||||
-- find all potential start points in the new data
|
-- 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;
|
where draft;
|
||||||
|]
|
|]
|
||||||
|
|
||||||
recents :: (MonadIO m) => ReaderT SqlBackend m [Session]
|
recents :: (MonadIO m) => ReaderT SqlBackend m [Session]
|
||||||
recents = do
|
recents = do
|
||||||
s <- selectList [SessionDraft !=. True] [Desc SessionStartTime, LimitTo 10]
|
s <- selectList [SessionDraft !=. True] [Desc SessionStartTime, LimitTo 10]
|
||||||
return $ Prelude.map (\(Entity _ x) -> x) s
|
return $ Prelude.map (\(Entity _ x) -> x) s
|
||||||
|
@ -27,10 +27,10 @@ import Data.Text.Lazy as T
|
|||||||
import Data.Time
|
import Data.Time
|
||||||
import Data.Time.ISO8601 qualified
|
import Data.Time.ISO8601 qualified
|
||||||
import Debug.Trace (trace, traceShow)
|
import Debug.Trace (trace, traceShow)
|
||||||
|
import Point
|
||||||
import Text.Read (readMaybe)
|
import Text.Read (readMaybe)
|
||||||
import Text.XML
|
import Text.XML
|
||||||
import Text.XML.Cursor as Cursor
|
import Text.XML.Cursor as Cursor
|
||||||
import Point
|
|
||||||
|
|
||||||
-- TODO do we even need this type?
|
-- TODO do we even need this type?
|
||||||
type Track = [Point]
|
type Track = [Point]
|
||||||
|
Loading…
Reference in New Issue
Block a user