change how tips are processed - per user

migrate-new-models
lza_menace 1 year ago
parent faebd00fd5
commit 159504f703

@ -55,18 +55,19 @@ def generate_data():
@bp.cli.command('process_tips')
def process_tips():
w = wownero.Wallet()
for post in Post.select().order_by(Post.timestamp.desc()):
print(f'Checking new tips for post {post.id}')
txes = w.transfers(config.WALLET_ACCOUNT, [post.address_index])
addr = w.get_address(config.WALLET_ACCOUNT, [post.address_index])
if post.address != addr['addresses'][0]['address']:
print(f'addresses dont match. skipping.')
for user in User.select().order_by(User.id.desc()):
user_posts = Post.select().where(Post.user == user)
if user_posts.count() == 0:
continue
addresses = [i.address_index for i in user_posts]
txes = w.transfers(config.WALLET_ACCOUNT, addresses)
if txes:
for tx in txes['in']:
if tx['unlock_time'] > 0:
print('someone added a lock time to this tx. skipping for now.')
continue
if tx['confirmations'] < 5:
continue
_tx = TipReceived.select().where(TipReceived.txid == tx['txid']).first()
if not _tx:
post = Post.select().where(Post.address == tx['address']).first()