Add expired status to cash-out txs
This commit is contained in:
parent
919848aecd
commit
9ca3e88495
7 changed files with 75 additions and 37 deletions
|
|
@ -50,6 +50,7 @@ type alias CashOutTxRec =
|
|||
, error : Maybe String
|
||||
, created : Date
|
||||
, confirmed : Bool
|
||||
, expired : Bool
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -104,3 +104,4 @@ cashOutTxDecoder =
|
|||
|> required "error" (nullable string)
|
||||
|> required "created" date
|
||||
|> required "confirmedAt" confirmedDecoder
|
||||
|> required "expired" bool
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import RemoteData exposing (..)
|
|||
import Common.TransactionTypes exposing (..)
|
||||
import Transaction.Types exposing (..)
|
||||
import Numeral exposing (format)
|
||||
import Maybe.Extra exposing (isJust)
|
||||
|
||||
|
||||
-- import Css.Admin exposing (..)
|
||||
|
|
@ -53,6 +54,15 @@ cashInTxView tx =
|
|||
cashOutTxView : CashOutTxRec -> Html Msg
|
||||
cashOutTxView tx =
|
||||
let
|
||||
cancelStatus =
|
||||
if isJust tx.error then
|
||||
"Error"
|
||||
else if tx.dispense then
|
||||
"Success"
|
||||
else if tx.expired then
|
||||
"Expired"
|
||||
else
|
||||
"Pending"
|
||||
error =
|
||||
case tx.error of
|
||||
Nothing ->
|
||||
|
|
@ -66,6 +76,7 @@ cashOutTxView tx =
|
|||
, div [] [ text "This is a cash-out transaction" ]
|
||||
, div [] [ text ("Fiat: " ++ (format "0,0.00" tx.fiat)) ]
|
||||
, div [] [ text ("Raw ticker price: " ++ (format "0,0.00" (Maybe.withDefault 0.0 tx.rawTickerPrice))) ]
|
||||
, div [] [ text ("Status: " ++ cancelStatus) ]
|
||||
, div [] [ text error ]
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -146,6 +146,8 @@ rowView tx =
|
|||
"Error"
|
||||
else if cashOut.dispense then
|
||||
"Success"
|
||||
else if cashOut.expired then
|
||||
"Expired"
|
||||
else
|
||||
"Pending"
|
||||
in
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const db = require('../db')
|
|||
const machineLoader = require('../machine-loader')
|
||||
const tx = require('../tx')
|
||||
const cashInTx = require('../cash-in/cash-in-tx')
|
||||
const { REDEEMABLE_AGE } = require('../cash-out/cash-out-helper')
|
||||
|
||||
const NUM_RESULTS = 1000
|
||||
|
||||
|
|
@ -31,11 +32,12 @@ function batch () {
|
|||
from cash_in_txs
|
||||
order by created desc limit $2`
|
||||
|
||||
const cashOutSql = `select 'cashOut' as tx_class, cash_out_txs.*
|
||||
const cashOutSql = `select 'cashOut' as tx_class, cash_out_txs.*,
|
||||
(extract(epoch from (now() - greatest(created, confirmed_at))) * 1000) >= $2 as expired
|
||||
from cash_out_txs
|
||||
order by created desc limit $1`
|
||||
|
||||
return Promise.all([db.any(cashInSql, [cashInTx.PENDING_INTERVAL, NUM_RESULTS]), db.any(cashOutSql, [NUM_RESULTS])])
|
||||
return Promise.all([db.any(cashInSql, [cashInTx.PENDING_INTERVAL, NUM_RESULTS]), db.any(cashOutSql, [NUM_RESULTS, REDEEMABLE_AGE])])
|
||||
.then(packager)
|
||||
}
|
||||
|
||||
|
|
@ -48,13 +50,15 @@ function single (txId) {
|
|||
from cash_in_txs
|
||||
where id=$2`
|
||||
|
||||
const cashOutSql = `select 'cashOut' as tx_class, cash_out_txs.*
|
||||
const cashOutSql = `select 'cashOut' as tx_class,
|
||||
(extract(epoch from (now() - greatest(created, confirmed_at))) * 1000) >= $2 as expired,
|
||||
cash_out_txs.*
|
||||
from cash_out_txs
|
||||
where id=$1`
|
||||
|
||||
return Promise.all([
|
||||
db.oneOrNone(cashInSql, [cashInTx.PENDING_INTERVAL, txId]),
|
||||
db.oneOrNone(cashOutSql, [txId])
|
||||
db.oneOrNone(cashOutSql, [txId, REDEEMABLE_AGE])
|
||||
])
|
||||
.then(packager)
|
||||
.then(_.head)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const BN = require('../bn')
|
|||
|
||||
const REDEEMABLE_AGE = T.day
|
||||
|
||||
module.exports = {redeemableTxs, toObj, toDb}
|
||||
module.exports = { redeemableTxs, toObj, toDb, REDEEMABLE_AGE }
|
||||
|
||||
const mapValuesWithKey = _.mapValues.convert({cap: false})
|
||||
|
||||
|
|
|
|||
|
|
@ -28514,7 +28514,9 @@ var _user$project$Common_TransactionTypes$CashOutTxRec = function (a) {
|
|||
return function (o) {
|
||||
return function (p) {
|
||||
return function (q) {
|
||||
return {id: a, machineName: b, toAddress: c, cryptoAtoms: d, cryptoCode: e, fiat: f, commissionPercentage: g, rawTickerPrice: h, fiatCode: i, status: j, dispense: k, notified: l, redeemed: m, phone: n, error: o, created: p, confirmed: q};
|
||||
return function (r) {
|
||||
return {id: a, machineName: b, toAddress: c, cryptoAtoms: d, cryptoCode: e, fiat: f, commissionPercentage: g, rawTickerPrice: h, fiatCode: i, status: j, dispense: k, notified: l, redeemed: m, phone: n, error: o, created: p, confirmed: q, expired: r};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -34029,6 +34031,10 @@ var _user$project$Transaction_Decoder$cashInTxDecoder = A3(
|
|||
_elm_lang$core$Json_Decode$string,
|
||||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$decode(_user$project$Common_TransactionTypes$CashInTxRec))))))))))))))))));
|
||||
var _user$project$Transaction_Decoder$cashOutTxDecoder = A3(
|
||||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
|
||||
'expired',
|
||||
_elm_lang$core$Json_Decode$bool,
|
||||
A3(
|
||||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
|
||||
'confirmedAt',
|
||||
_user$project$Transaction_Decoder$confirmedDecoder,
|
||||
|
|
@ -34096,7 +34102,7 @@ var _user$project$Transaction_Decoder$cashOutTxDecoder = A3(
|
|||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
|
||||
'id',
|
||||
_elm_lang$core$Json_Decode$string,
|
||||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$decode(_user$project$Common_TransactionTypes$CashOutTxRec))))))))))))))))));
|
||||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$decode(_user$project$Common_TransactionTypes$CashOutTxRec)))))))))))))))))));
|
||||
var _user$project$Transaction_Decoder$txDecode = function (txClass) {
|
||||
var _p4 = txClass;
|
||||
switch (_p4) {
|
||||
|
|
@ -34374,7 +34380,7 @@ var _user$project$Transactions$rowView = function (tx) {
|
|||
});
|
||||
} else {
|
||||
var _p4 = _p2._0;
|
||||
var status = _elm_community$maybe_extra$Maybe_Extra$isJust(_p4.error) ? 'Error' : (_p4.dispense ? 'Success' : 'Pending');
|
||||
var status = _elm_community$maybe_extra$Maybe_Extra$isJust(_p4.error) ? 'Error' : (_p4.dispense ? 'Success' : (_p4.expired ? 'Expired' : 'Pending'));
|
||||
return A2(
|
||||
_elm_lang$html$Html$tr,
|
||||
{
|
||||
|
|
@ -39152,6 +39158,7 @@ var _user$project$Transaction_View$cashOutTxView = function (tx) {
|
|||
return A2(_elm_lang$core$Basics_ops['++'], 'Error: ', _p0._0);
|
||||
}
|
||||
}();
|
||||
var cancelStatus = _elm_community$maybe_extra$Maybe_Extra$isJust(tx.error) ? 'Error' : (tx.dispense ? 'Success' : (tx.expired ? 'Expired' : 'Pending'));
|
||||
return A2(
|
||||
_elm_lang$html$Html$div,
|
||||
{ctor: '[]'},
|
||||
|
|
@ -39206,6 +39213,17 @@ var _user$project$Transaction_View$cashOutTxView = function (tx) {
|
|||
A2(_elm_lang$core$Maybe$withDefault, 0.0, tx.rawTickerPrice)))),
|
||||
_1: {ctor: '[]'}
|
||||
}),
|
||||
_1: {
|
||||
ctor: '::',
|
||||
_0: A2(
|
||||
_elm_lang$html$Html$div,
|
||||
{ctor: '[]'},
|
||||
{
|
||||
ctor: '::',
|
||||
_0: _elm_lang$html$Html$text(
|
||||
A2(_elm_lang$core$Basics_ops['++'], 'Status: ', cancelStatus)),
|
||||
_1: {ctor: '[]'}
|
||||
}),
|
||||
_1: {
|
||||
ctor: '::',
|
||||
_0: A2(
|
||||
|
|
@ -39221,6 +39239,7 @@ var _user$project$Transaction_View$cashOutTxView = function (tx) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
var _user$project$Transaction_View$cashInTxView = function (tx) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue