update scripts

migrate-new-models
lza_menace 2 years ago
parent 7010790739
commit a6aea485af

@ -50,8 +50,13 @@ for post in all_data['posts']:
if 'in' in post['txes']:
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'])
amount = sum(tx['amounts'])
received = TipReceived.select().where(
TipReceived.txid == tx['txid'],
TipReceived.amount == amount,
TipReceived.post == p
).first()
if not received:
TipReceived.create(
post=p,
timestamp=datetime.utcfromtimestamp(tx['timestamp']),

@ -156,7 +156,8 @@ class Post(Model):
'approved': self.approved,
'approved_by': self.approved_by,
'received_wow': self.get_wow_received(),
'hours_elapsed': self.hours_elapsed()
'hours_elapsed': self.hours_elapsed(),
'tips_received': [tip for tip in TipReceived.select().where(TipReceived.post == self)]
}
class Meta:
@ -195,7 +196,7 @@ class AuditEvent(Model):
class TipReceived(Model):
id = AutoField()
post = ForeignKeyField(Post)
txid = CharField(unique=True)
txid = CharField()
timestamp = DateTimeField()
amount = IntegerField()
fee = IntegerField()
@ -208,7 +209,7 @@ class TipSent(Model):
id = AutoField()
from_user = ForeignKeyField(User)
to_user = ForeignKeyField(User)
txid = CharField(unique=True)
txid = CharField()
timestamp = DateTimeField()
amount = IntegerField()
fee = IntegerField()

@ -0,0 +1,7 @@
#!/bin/bash
rsync -avzP australia:/opt/suchwow/data/uploads/ data/uploads/
rsync -avzP australia:/opt/suchwow/data/sqlite.db data/sqlite.db
rsync -avzP australia:/opt/suchwow/data/migrate_data.pkl data/migrate_data.pkl
.venv/bin/python3 import.py
Loading…
Cancel
Save