Completed conversion to snap.
[?]
Dec 21, 2014, 8:05 PM
TCOAKCGGHOIRJCTZYEZQ3K6KCGL2LGAYGYFRGSPCHBTJJY2V6AXACDependencies
- [2]
WFZDMVUXRename ADB -> QDB - [3]
EMVTF2IWWIP moving back to snap. - [4]
64VI73NPServer now compiles using abstracted SQLite - [5]
ADMKQQGCInitial empty Snap project. - [6]
WO2MINIFAuctions now compile! - [7]
Z3M53KTLAdrift. - [8]
RSEB2NFGReplacing Snap with Scotty. - [9]
64C6AWH6Rename Ananke -> Quixotic, project reboot. - [10]
WZUHEZSBStart of migration back toward snap. - [11]
LAROLAYUWIP
Change contents
- edit in quixotic.cabal at line 19
Quixotic.Auction - replacement in quixotic.cabal at line 70
, sqlite, lens, sqlite-simple - edit in quixotic.cabal at line 74
, transformers - edit in server/Main.hs at line 2
{-# LANGUAGE RecordWildCards #-} - replacement in server/Main.hs at line 4
module Main (main) wheremodule Main where - replacement in server/Main.hs at line 6
import ClassyPreludeimport ClassyPrelude - replacement in server/Main.hs at line 8
import Control.Applicativeimport Control.Monad.Trans (liftIO)import Control.Monad.Trans.Eitherimport Control.Lensimport Control.Monad.Trans.Reader - replacement in server/Main.hs at line 14[3.122]→[3.122:160](∅→∅),[3.160]→[3.2455:2478](∅→∅),[3.2455]→[3.2455:2478](∅→∅),[3.2478]→[3.161:184](∅→∅)
import qualified Data.Text.Lazy as LTimport Data.Time.Clockimport Database.SQLiteimport Database.SQLite.Simple - edit in server/Main.hs at line 20
import Snap.Util.FileServe - replacement in server/Main.hs at line 25[3.189]→[3.6250:6287](∅→∅),[3.6287]→[2.184:206](∅→∅),[2.206]→[3.6288:6332](∅→∅),[3.288]→[3.6288:6332](∅→∅)
db <- openConnection $ dbName cfgadb <- sqliteQDB dbquickHttpServe $ runReaderT (site adb) dbdb <- open $ dbName cfgquickHttpServe $ runReaderT (site sqliteQDB) db - replacement in server/Main.hs at line 29
site adb = route[ ("logStart/:btcAddr", handleLogRequest adb StartWork), ("logEnd/:btcAddr", handleLogRequest adb StopWork), ("payouts", currentPayouts adb)site qdb = route[ ("logStart/:btcAddr", handleLogRequest qdb StartWork), ("logEnd/:btcAddr", handleLogRequest qdb StopWork), ("payouts", currentPayouts qdb) - replacement in server/Main.hs at line 42
cfg <- C.load [C.Required cfgFile]cfg <- C.load [C.Required (fpToString cfgFile)] - replacement in server/Main.hs at line 45[3.5696]→[2.246:322](∅→∅),[2.322]→[3.587:620](∅→∅),[3.2027]→[3.587:620](∅→∅),[3.6622]→[3.587:620](∅→∅),[3.587]→[3.587:620](∅→∅)
handleLogRequest :: QDB IO a -> (UTCTime -> WorkEvent) -> ReaderT a Snap ()handleLogRequest db adb ev = dohandleLogRequest :: QDB IO a -> EventType -> ReaderT a Snap ()handleLogRequest qdb ev = dolet QDB{..} = qdb - replacement in server/Main.hs at line 49[3.6664]→[3.2062:2115](∅→∅),[3.2062]→[3.2062:2115](∅→∅),[3.2115]→[3.2943:2980](∅→∅),[3.2943]→[3.2943:2980](∅→∅),[3.2980]→[3.621:682](∅→∅)
let addr = fmap T.pack addrBytes >>= parseBtcAddrtimestamp <- liftIO getCurrentTimeliftIO $ recordEvent adb db $ LogEntry addr (ev timestamp)timestamp <- lift $ liftIO getCurrentTimemaybe(lift $ snapError 400 "")(\a -> mapReaderT liftIO $ recordEvent (LogEntry a (WorkEvent ev timestamp)))(fmap decodeUtf8 addrBytes >>= parseBtcAddr) - replacement in server/Main.hs at line 56[2.371]→[3.729:757](∅→∅),[3.2159]→[3.729:757](∅→∅),[3.6713]→[3.729:757](∅→∅),[3.729]→[3.729:757](∅→∅),[3.757]→[3.3100:3188](∅→∅),[3.3100]→[3.3100:3188](∅→∅)
currentPayouts db adb = doptime <- liftIO getCurrentTimelet dep = linearDepreciation (Months 6) (Months 60)currentPayouts qdb = dolet QDB{..} = qdbdep = linearDepreciation (Months 6) (Months 60) - replacement in server/Main.hs at line 60[3.759]→[3.2160:2211](∅→∅),[3.2211]→[3.1483:1579](∅→∅),[3.895]→[3.6168:6169](∅→∅),[3.1579]→[3.6168:6169](∅→∅),[3.2086]→[3.6168:6169](∅→∅),[3.2305]→[3.6168:6169](∅→∅),[3.3259]→[3.6168:6169](∅→∅),[3.6168]→[3.6168:6169](∅→∅),[3.6169]→[3.2306:2359](∅→∅),[3.2359]→[3.952:1016](∅→∅),[3.952]→[3.952:1016](∅→∅)
buildPayoutsResponse :: WorkIndex -> Snap ()buildPayoutsResponse widx = writeBS . A.encode . PayoutsResponse $ payouts dep ptime widxpayoutsAction :: EitherT T.Text Snap WorkIndexpayoutsAction = mapEitherT liftIO $ readWorkIndex adb dbptime <- lift . liftIO $ getCurrentTimewidx <- mapReaderT liftIO $ readWorkIndexlift . writeLBS . A.encode . PayoutsResponse $ payouts dep ptime widx - replacement in server/Main.hs at line 64
lift $ eitherT (raise . LT.fromStrict) buildPayoutsResponse payoutsActionsnapError :: Int -> Text -> Snap ()snapError c t = domodifyResponse $ setResponseStatus c $ encodeUtf8 twriteText $ ((tshow c) <> " - " <> t)r <- getResponsefinishWith r - replacement in server/Main.hs at line 76
m = fmap fromRational (mapKeys address p)[3.645]m = fmap fromRational $ mapKeys (^. address) p