update import/export scripts

This commit is contained in:
lza_menace 2022-09-04 10:12:57 -07:00
parent ccb48a16c2
commit df33eaf258
2 changed files with 9 additions and 5 deletions

View File

@ -12,7 +12,7 @@ if not wallet.connected:
print('Wallet not connected')
exit()
all_posts = Post.select()
all_posts = Post.select().order_by(Post.timestamp.desc())
all_mods = Moderator.select()
all_profiles = Profile.select()
all_bans = Ban.select()
@ -27,7 +27,7 @@ all_data = {
for post in all_posts:
all_data['posts'].append({
post_data = {
'id': post.id,
'title': post.title,
'text': post.text,
@ -43,7 +43,9 @@ for post in all_posts:
'to_discord': post.to_discord,
'approved': post.approved,
'txes': wallet.transfers(post.account_index)
})
}
all_data['posts'].append(post_data)
print(post_data['txes'])
for mod in all_mods:
all_data['moderators'].append(mod.username)

View File

@ -51,11 +51,12 @@ for post in all_data['posts']:
p = Post.get(post['id'])
for tx in post['txes']['in']:
if not TipReceived.select().where(TipReceived.txid == tx['txid']).first():
amount = sum(tx['amounts'])
TipReceived.create(
post=p,
timestamp=datetime.utcfromtimestamp(tx['timestamp']),
txid=tx['txid'],
amount=sum(tx['amounts']),
amount=amount,
fee=tx['fee']
)
print(f'Saving received tip txid {tx["txid"]}')
@ -65,7 +66,8 @@ for post in all_data['posts']:
for tx in post['txes']['out']:
if not TipSent.select().where(TipSent.txid == tx['txid']).first():
TipSent.create(
user=p.user,
from_user=p.user,
to_user=p.user,
txid=tx['txid'],
timestamp=datetime.utcfromtimestamp(tx['timestamp']),
amount=tx['amount'],