<commit_before>import json
from threading import Timer, enumerate
import sqlite3
from bitcoinrpc.authproxy import JSONRPCException

__author__ = 'sammoth'


def pay(rpc, log, start_timer=True):
    """
    Pay all users who have a balance > 1 NBT
    :return:
    """
    # reset timer
    if start_timer:
        payout_timer = Timer(86400.0, pay,
                             kwargs={'rpc': rpc, 'log': log})
        payout_timer.name = 'payout_timer'
        payout_timer.daemon = True
        payout_timer.start()
    log.info('Payout')
    # get the credit details from the database
    conn = sqlite3.connect('pool.db')
    db = conn.cursor()
    rewards = db.execute("SELECT c.id,c.user,c.reward,u.address "
                         "FROM credits AS c INNER JOIN users AS u on "
                         "u.user=c.user WHERE c.rank=1 AND c.paid=0").fetchall()
    conn.close()
    # Calculate the total credit for each unique address
    user_rewards = {}
    for reward in rewards:
        if reward[3] not in user_rewards:
            user_rewards[reward[3]] = 0.00<commit_msg>update timmer restart and calculate next payut time<commit_after>import json
from threading import Timer
import time
import database
from bitcoinrpc.authproxy import JSONRPCException

__author__ = 'sammoth'


def pay(app, rpc, log):
    """
    Pay all users who have a balance > 1 NBT
    :return:
    """
    # reset timer
    payout_timer = Timer(86400.0, pay,
                         kwargs={'rpc': rpc, 'log': log})
    payout_timer.name = 'payout_timer'
    payout_timer.daemon = True
    payout_timer.start()
    log.info('Payout')
    # get the credit details from the database
    conn = database.get_db(app)
    db = conn.cursor()
    db.execute('UPDATE info SET value=? WHERE key=?', ((time.time() + 86400),
                                                       'next_payout_time'))
    rewards = db.execute("SELECT c.id,c.user,c.reward,u.address "
                         "FROM credits AS c INNER JOIN users AS u on "
                         "u.user=c.user WHERE c.rank=1 AND c.paid=0").fetchall()
    conn.commit()
    conn.close()
    # Calculate the total credit for each unique address
    user_rewards = {}
    for reward in rewards:
        if reward[3] not in user_rewards:
            user_rewards[reward[3]] = 0.00
{'fraction_non_alphanumeric': 0.1032258064516129, 'fraction_numerical': 0.015053763440860216, 'mean_word_length': 2.2531468531468533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3243095', 'n_tokens_mistral': 735, 'n_tokens_neox': 704, 'n_words': 207}