Use new History shema with paginiation
This commit is contained in:
parent
24a58e7e03
commit
66c2070ef8
|
@ -28,28 +28,34 @@ class History:
|
||||||
queryBuild = gql(
|
queryBuild = gql(
|
||||||
"""
|
"""
|
||||||
query ($pubkey: String!){
|
query ($pubkey: String!){
|
||||||
transactionsHistory(pubkey: $pubkey) {
|
txsHistoryBc(
|
||||||
received {
|
pubkeyOrScript: $pubkey
|
||||||
|
pagination: { pageSize: 10, ord: DESC }
|
||||||
|
) {
|
||||||
|
both {
|
||||||
|
pageInfo {
|
||||||
|
hasPreviousPage
|
||||||
|
hasNextPage
|
||||||
|
}
|
||||||
|
edges {
|
||||||
|
direction
|
||||||
|
node {
|
||||||
|
currency
|
||||||
|
issuers
|
||||||
|
outputs
|
||||||
|
comment
|
||||||
|
writtenTime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
txsHistoryMp(pubkey: $pubkey) {
|
||||||
|
receiving {
|
||||||
|
currency
|
||||||
|
issuers
|
||||||
|
comment
|
||||||
|
outputs
|
||||||
writtenTime
|
writtenTime
|
||||||
issuers
|
|
||||||
outputs
|
|
||||||
comment
|
|
||||||
}
|
|
||||||
sent {
|
|
||||||
writtenTime
|
|
||||||
issuers
|
|
||||||
outputs
|
|
||||||
comment
|
|
||||||
}
|
|
||||||
receiving {
|
|
||||||
issuers
|
|
||||||
outputs
|
|
||||||
comment
|
|
||||||
}
|
|
||||||
sending {
|
|
||||||
issuers
|
|
||||||
outputs
|
|
||||||
comment
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balance(script: $pubkey) {
|
balance(script: $pubkey) {
|
||||||
|
@ -88,34 +94,33 @@ class History:
|
||||||
currentBase = int(self.historyDoc['currentUd']['base'])
|
currentBase = int(self.historyDoc['currentUd']['base'])
|
||||||
self.UD = self.historyDoc['currentUd']['amount']/100
|
self.UD = self.historyDoc['currentUd']['amount']/100
|
||||||
|
|
||||||
for sens in 'received','sent','receiving','sending':
|
|
||||||
res = self.historyDoc['transactionsHistory'][sens]
|
resBc = self.historyDoc['txsHistoryBc']['both']['edges'][0]
|
||||||
for bloc in res:
|
for transaction in resBc:
|
||||||
output = bloc['outputs'][0]
|
direction = resBc['direction']
|
||||||
outPubkey = output.split("SIG(")[1].replace(')','')
|
transaction = resBc['node']
|
||||||
if sens in ('received','receiving') or self.pubkey != outPubkey:
|
output = transaction['outputs'][0]
|
||||||
trans.append(i)
|
outPubkey = output.split("SIG(")[1].replace(')','')
|
||||||
trans[i] = []
|
if direction == 'RECEIVED' or self.pubkey != outPubkey:
|
||||||
trans[i].append(sens)
|
trans.append(i)
|
||||||
if sens in ('receiving','sending'):
|
trans[i] = []
|
||||||
trans[i].append(int(time.time()))
|
trans[i].append(direction)
|
||||||
else:
|
trans[i].append(transaction['writtenTime'])
|
||||||
trans[i].append(bloc['writtenTime'])
|
if direction == 'SENT':
|
||||||
if sens in ('sent','sending'):
|
trans[i].append(outPubkey)
|
||||||
trans[i].append(outPubkey)
|
amount = int('-' + output.split(':')[0])
|
||||||
amount = int('-' + output.split(':')[0])
|
else:
|
||||||
else:
|
trans[i].append(transaction['issuers'][0])
|
||||||
trans[i].append(bloc['issuers'][0])
|
amount = int(output.split(':')[0])
|
||||||
amount = int(output.split(':')[0])
|
base = int(output.split(':')[1])
|
||||||
base = int(output.split(':')[1])
|
applyBase = base-currentBase
|
||||||
applyBase = base-currentBase
|
amount = round(amount*pow(10,applyBase)/100, 2)
|
||||||
amount = round(amount*pow(10,applyBase)/100, 2)
|
# if referential == 'DU': amount = round(amount/UD, 2)
|
||||||
# if referential == 'DU': amount = round(amount/UD, 2)
|
trans[i].append(amount)
|
||||||
trans[i].append(amount)
|
trans[i].append(round(amount/self.UD, 2))
|
||||||
trans[i].append(round(amount/self.UD, 2))
|
trans[i].append(transaction['comment'])
|
||||||
trans[i].append(bloc['comment'])
|
trans[i].append(base)
|
||||||
trans[i].append(base)
|
i += 1
|
||||||
i += 1
|
|
||||||
|
|
||||||
# Order transactions by date
|
# Order transactions by date
|
||||||
trans.sort(key=lambda x: x[1])
|
trans.sort(key=lambda x: x[1])
|
||||||
|
|
Loading…
Reference in New Issue