added order-overview page. still needs tweaking and polish.
This commit is contained in:
parent
a8df1abfa1
commit
4016194ecb
@ -37,6 +37,7 @@ import Handler.Settings
|
|||||||
import Handler.Update
|
import Handler.Update
|
||||||
import Handler.Stock
|
import Handler.Stock
|
||||||
import Handler.ProfitItems
|
import Handler.ProfitItems
|
||||||
|
import Handler.Orders
|
||||||
|
|
||||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
-- 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
|
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||||
|
64
Handler/Orders.hs
Normal file
64
Handler/Orders.hs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
|
||||||
|
module Handler.Orders where
|
||||||
|
|
||||||
|
import Import
|
||||||
|
import Database.Persist.Sql
|
||||||
|
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
|
||||||
|
loginLayout user [whamlet|
|
||||||
|
<div .panel .panel-default>
|
||||||
|
<div .panel-heading>Current Sell Orders:
|
||||||
|
<table .table .table-condensed .small>
|
||||||
|
<tr>
|
||||||
|
<th .text-center>Last changed
|
||||||
|
<th .text-center>Item
|
||||||
|
<th .text-center>Price
|
||||||
|
<th .text-center>Quantity (min)
|
||||||
|
<th .text-center>Range
|
||||||
|
<th .text-center>Duration
|
||||||
|
<th .text-center>Escrow
|
||||||
|
<th .text-center>Station
|
||||||
|
$forall (Entity _ o, Single name) <- sellorders
|
||||||
|
<tr>
|
||||||
|
<td>#{showDateTime $ orderIssued $ o}
|
||||||
|
<td>#{name}
|
||||||
|
<td .numeric>#{prettyISK $ orderPriceCents o}
|
||||||
|
<td .numeric>#{orderVolRemaining o}/#{orderVolEntered o} (#{orderMinVolume o})
|
||||||
|
<td .numeric>Range
|
||||||
|
<td .numeric>#{orderDuration o}
|
||||||
|
<td .numeric>#{prettyISK $ orderEscrowCents o}
|
||||||
|
<td>StationName
|
||||||
|
|
||||||
|
<div .panel .panel-default>
|
||||||
|
<div .panel-heading>Current Buy Orders:
|
||||||
|
<table .table .table-condensed .small>
|
||||||
|
<tr>
|
||||||
|
<th .text-center>Last changed
|
||||||
|
<th .text-center>Item
|
||||||
|
<th .text-center>Price
|
||||||
|
<th .text-center>Quantity (min)
|
||||||
|
<th .text-center>Range
|
||||||
|
<th .text-center>Duration
|
||||||
|
<th .text-center>Escrow
|
||||||
|
<th .text-center>Station
|
||||||
|
$forall (Entity _ o, Single name) <- buyorders
|
||||||
|
<tr>
|
||||||
|
<td>#{showDateTime $ orderIssued $ o}
|
||||||
|
<td>#{name}
|
||||||
|
<td .numeric>#{prettyISK $ orderPriceCents o}
|
||||||
|
<td .numeric>#{orderVolRemaining o}/#{orderVolEntered o} (#{orderMinVolume o})
|
||||||
|
<td .numeric>Range
|
||||||
|
<td .numeric>#{orderDuration o}
|
||||||
|
<td .numeric>#{prettyISK $ orderEscrowCents o}
|
||||||
|
<td>StationName
|
||||||
|
|
||||||
|
|]
|
||||||
|
)
|
@ -108,7 +108,7 @@ getUpdateR = loginOrDo (\(uid,user) -> do
|
|||||||
update uid [UserOrderTimeout =. time']
|
update uid [UserOrderTimeout =. time']
|
||||||
--update escrow-worth (cache)
|
--update escrow-worth (cache)
|
||||||
let ordersql = "update \"user\" set \
|
let ordersql = "update \"user\" set \
|
||||||
escrow_cents = COALESCE((select sum(escrow_cents) from \"order\" where \"user\"=\"user\".id),0) \
|
escrow_cents = COALESCE((select sum(escrow_cents) from \"order\" where \"user\"=\"user\".id and \"order\".order_state=0),0) \
|
||||||
where id=?"
|
where id=?"
|
||||||
rawExecute ordersql [toPersistValue uid]
|
rawExecute ordersql [toPersistValue uid]
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
@ -13,3 +13,4 @@
|
|||||||
/stock StockR GET
|
/stock StockR GET
|
||||||
/analysis/items ProfitItemsR GET
|
/analysis/items ProfitItemsR GET
|
||||||
/analysis/items/#Int64 ProfitItemsDetailsR GET
|
/analysis/items/#Int64 ProfitItemsDetailsR GET
|
||||||
|
/orders OrdersR GET
|
||||||
|
@ -27,6 +27,7 @@ library
|
|||||||
Handler.Update
|
Handler.Update
|
||||||
Handler.Stock
|
Handler.Stock
|
||||||
Handler.ProfitItems
|
Handler.ProfitItems
|
||||||
|
Handler.Orders
|
||||||
|
|
||||||
if flag(dev) || flag(library-only)
|
if flag(dev) || flag(library-only)
|
||||||
cpp-options: -DDEVELOPMENT
|
cpp-options: -DDEVELOPMENT
|
||||||
|
@ -46,6 +46,7 @@ $newline never
|
|||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Analysis <span class="caret"></span>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Analysis <span class="caret"></span>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="@{ProfitItemsR}">Profitable Items</a>
|
<li><a href="@{ProfitItemsR}">Profitable Items</a>
|
||||||
|
<li><a href="@{OrdersR}">Orders</a>
|
||||||
<!--li><a href="#">Another action</a>
|
<!--li><a href="#">Another action</a>
|
||||||
<li><a href="#">Something else here</a>
|
<li><a href="#">Something else here</a>
|
||||||
<li role="separator" class="divider">
|
<li role="separator" class="divider">
|
||||||
|
10
test/Handler/OrdersSpec.hs
Normal file
10
test/Handler/OrdersSpec.hs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module Handler.OrdersSpec (spec) where
|
||||||
|
|
||||||
|
import TestImport
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec = withApp $ do
|
||||||
|
|
||||||
|
describe "getOrdersR" $ do
|
||||||
|
error "Spec not implemented: getOrdersR"
|
||||||
|
|
10
test/Handler/ProfitItemsSpec.hs
Normal file
10
test/Handler/ProfitItemsSpec.hs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module Handler.ProfitItemsSpec (spec) where
|
||||||
|
|
||||||
|
import TestImport
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec = withApp $ do
|
||||||
|
|
||||||
|
describe "getProfitItemsR" $ do
|
||||||
|
error "Spec not implemented: getProfitItemsR"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user