From 445bd85ce4d1d862b44f764bd944915803da3a83 Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Fri, 18 Sep 2015 17:59:50 +0200 Subject: [PATCH] added structure for problematic transactions --- Application.hs | 1 + Handler/Problematic.hs | 25 +++++++++++++++++++++++++ config/routes | 2 ++ neat.cabal | 1 + test/Handler/ProblematicSpec.hs | 10 ++++++++++ 5 files changed, 39 insertions(+) create mode 100644 Handler/Problematic.hs create mode 100644 test/Handler/ProblematicSpec.hs diff --git a/Application.hs b/Application.hs index b30cadd..eec1f1c 100644 --- a/Application.hs +++ b/Application.hs @@ -39,6 +39,7 @@ import Handler.Stock import Handler.ProfitItems import Handler.Orders import Handler.Item +import Handler.Problematic -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the diff --git a/Handler/Problematic.hs b/Handler/Problematic.hs new file mode 100644 index 0000000..d6e2804 --- /dev/null +++ b/Handler/Problematic.hs @@ -0,0 +1,25 @@ +module Handler.Problematic where + +import Import + +problematicDaysInterval :: [Int] +problematicDaysInterval = [1,2,7,14,31] + +getProblematicR :: Handler Html +getProblematicR = getProblematicDaysR 1 + +getProblematicDaysR :: Int -> Handler Html +getProblematicDaysR days = loginOrDo (\(uid,user) -> do + let rawSQL = "select \ + max(date_time), trans_for_corp, trans_is_sell, type_id, type_name, sum(quantity) as quantity, \ + sum(in_stock) as in_stock, sum(price_cents) as price_cents, station_id, station_name \ + from \ + transaction \ + where \ + \"user\"=? and CURRENT_TIMESTAMP - date_time < INTERVAL '? day' and problematic \ + group by type_id, trans_for_corp, trans_is_sell, type_name, station_id, station_name \ + order by max(date_time) desc" + loginLayout user $ [whamlet| + Not yet implemented. + |] + ) diff --git a/config/routes b/config/routes index acd7fef..8cdea22 100644 --- a/config/routes +++ b/config/routes @@ -16,3 +16,5 @@ /orders OrdersR GET /history/#Int64 ItemR GET /history/#Int64/#Int ItemPagedR GET +/transactions/problematic ProblematicR GET +/transactions/problematic/#Int ProblematicDaysR GET diff --git a/neat.cabal b/neat.cabal index abbe85c..1549901 100644 --- a/neat.cabal +++ b/neat.cabal @@ -29,6 +29,7 @@ library Handler.ProfitItems Handler.Orders Handler.Item + Handler.Problematic if flag(dev) || flag(library-only) cpp-options: -DDEVELOPMENT diff --git a/test/Handler/ProblematicSpec.hs b/test/Handler/ProblematicSpec.hs new file mode 100644 index 0000000..ac40f4c --- /dev/null +++ b/test/Handler/ProblematicSpec.hs @@ -0,0 +1,10 @@ +module Handler.ProblematicSpec (spec) where + +import TestImport + +spec :: Spec +spec = withApp $ do + + describe "getProblematicR" $ do + error "Spec not implemented: getProblematicR" +