diff --git a/Foundation.hs b/Foundation.hs index 3d151e7..fbc52e4 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -69,6 +69,7 @@ instance Yesod App where addStylesheet $ StaticR css_neat_css addScript $ StaticR js_jquery_js addScript $ StaticR js_bootstrap_js + addScript $ StaticR js_neat_js $(widgetFile "default-layout") withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet") diff --git a/Handler/Orders.hs b/Handler/Orders.hs index 3e0ae8d..f6d064f 100644 --- a/Handler/Orders.hs +++ b/Handler/Orders.hs @@ -9,56 +9,100 @@ import qualified Eve.Api.Char.MarketOrders as MO getOrdersR :: Handler Html getOrdersR = loginOrDo (\(uid,user) -> do -- using raw because model does not know about CCP-Data-Dump - let sql = "select ??, t.\"typeName\" from \"order\" join \"invTypes\" t on (\"order\".type_id = t.\"typeID\") where \"user\"=? order by \"order\".is_sell asc, t.\"typeName\" asc" - (orders :: [(Entity Order, Single Text)]) <- runDB $ rawSql sql [toPersistValue uid] - let sellorders = filter (\(Entity _ o, _) -> orderIsSell o && orderOrderState o == (fromIntegral . fromEnum) MO.Open) orders - let buyorders = filter (\(Entity _ o, _) -> not (orderIsSell o) && orderOrderState o == (fromIntegral . fromEnum) MO.Open) orders + let sql = "select ??, t.\"typeName\", s.\"stationName\", s.\"regionID\" from \"order\" join \"invTypes\" t on (\"order\".type_id = t.\"typeID\") join \"staStations\" s on (\"order\".station_id = s.\"stationID\") where \"user\"=? order by \"order\".is_sell asc, t.\"typeName\" asc" + (orders :: [(Entity Order, Single Text, Single Text, Single Text)]) <- runDB $ rawSql sql [toPersistValue uid] + let f = \(a,_,_,_) -> a + let sellorders = filter (\(Entity _ o, _, _, _) -> orderIsSell o && orderOrderState o == (fromIntegral . fromEnum) MO.Open) orders + let sellsum = foldl' sumOrders 0 (f <$> sellorders) + let sellescrow = foldl' sumEscrow 0 (f <$> sellorders) + let buyorders = filter (\(Entity _ o, _, _, _) -> not (orderIsSell o) && orderOrderState o == (fromIntegral . fromEnum) MO.Open) orders + let buysum = foldl' sumOrders 0 (f <$> buyorders) + let buyescrow = foldl' sumEscrow 0 (f <$> buyorders) loginLayout user [whamlet| +
+
+