refresh account age

This commit is contained in:
CHIEFSOFT\ameye
2025-03-31 16:59:56 -04:00
parent 8970c74904
commit ae5c46a1df
+30
View File
@@ -693,8 +693,38 @@ def generate_simulation_transaction():
def generate_simulation_credit():
pass
def refresh_accounts():
SQL_ACC_f ="SELECT accountid,counters FROM customer_account_list WHERE counters > 10 AND created IS NULL LIMIT 1000"
print(SQL_ACC_f)
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(SQL_ACC_f)
select_demoS = cursor.fetchall()
account_data = json.dumps( [dict(ix) for ix in select_demoS] )
accounts_result = json.loads( account_data)
trx_start_date = date.today()
date_format = "%d-%m-%Y"
for item in accounts_result:
accountid = item["accountid"].strip()
counters = item["counters"]
days_to_add = 365*random.randint(2,15) + counters * 28 + random.randint(0, 5)
days_to_created = trx_start_date - timedelta(days=days_to_add)
SQLUP = "UPDATE customer_account_list SET created = '" + str(days_to_created) + "' WHERE accountid ='" + accountid + "'"
print(SQLUP)
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(SQLUP)
return []
@app.route('/transaction/generator')
def generate_transactions():
refresh_accounts()
# SQL_ACC = "SELECT id, accountid,counters FROM customer_account_list WHERE counters > 0 AND counters < 14 ORDER by counters, id ASC LIMIT 700"
SQL_ACC = "SELECT id, accountid,counters FROM customer_account_list WHERE counters > 0 AND counters < 14 ORDER by counters, id ASC LIMIT 700"
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor: