-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.py
More file actions
28 lines (21 loc) · 793 Bytes
/
test.py
File metadata and controls
28 lines (21 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from server.models import Transaction, TransactionIndex
from tqdm import tqdm
from pony import orm
with orm.db_session:
transactions = Transaction.select()
for transaction in tqdm(transactions):
indexes = {}
for vout in transaction.outputs:
if vout.currency not in indexes:
indexes[vout.currency] = 0
indexes[vout.currency] += vout.amount
for currency in indexes:
if TransactionIndex.get(currency=currency, transaction=transaction):
continue
TransactionIndex(**{
"created": transaction.created,
"amount": indexes[currency],
"transaction": transaction,
"currency": currency,
})
orm.commit()