From ff9bc6a4521f24e6b7c5f4f2ea18737f6cae59c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20G=C3=A4rtner?= Date: Fri, 21 Oct 2022 14:56:46 +0300 Subject: [PATCH 1/3] added a variable mintLimit Since i have not run this as a dag yet this is the first attempt at this. --- create-tokens.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/create-tokens.py b/create-tokens.py index e5cf549..9b0dccb 100644 --- a/create-tokens.py +++ b/create-tokens.py @@ -58,10 +58,12 @@ def create_tokens(ds, **kwargs): walletName = kwargs['dag_run'].conf.get('walletName') entityId = kwargs['dag_run'].conf.get('entityId') dryRun = kwargs['dag_run'].conf.get('dryRun') + mintLimit = kwards['dag_run'].conf.get('mintLimit') # print them out print('walletName:', walletName) print('entityId:', entityId) print('dryRun:', dryRun) + print('mintLimit:', mintLimit) # check if wallet exists if walletName is None: print('walletName is None') @@ -72,7 +74,10 @@ def create_tokens(ds, **kwargs): if dryRun is None: print('dryRun is None') return - + if mintLimit is None: + print('mintLimit is None') + return + result = 'pending' db = PostgresHook(postgres_conn_id='postgres_default') connection = db.get_conn() @@ -108,15 +113,15 @@ def create_tokens(ds, **kwargs): AND active = true AND approved = true AND token_id IS NULL - LIMIT 3000 + LIMIT .format(mintLimit) """.format(entityId)) trees = cursor.fetchall() print('Trees found', len(trees)) - # check trees length < 3000 - if len(trees) < 3000: - print('Not more trees') + # check trees length < mintLimit + if len(trees) < mintLimit: + print('Less tokens than the mintLimit will be minted') remaining = False # for each tree, create a token From ec6f4af91d6946ff3f82872ff503d2c7de189c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20G=C3=A4rtner?= Date: Tue, 25 Oct 2022 09:25:04 +0300 Subject: [PATCH 2/3] Update create-tokens.py --- create-tokens.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-tokens.py b/create-tokens.py index 9b0dccb..1a0db04 100644 --- a/create-tokens.py +++ b/create-tokens.py @@ -58,7 +58,7 @@ def create_tokens(ds, **kwargs): walletName = kwargs['dag_run'].conf.get('walletName') entityId = kwargs['dag_run'].conf.get('entityId') dryRun = kwargs['dag_run'].conf.get('dryRun') - mintLimit = kwards['dag_run'].conf.get('mintLimit') + mintLimit = kwargs['dag_run'].conf.get('mintLimit') # print them out print('walletName:', walletName) print('entityId:', entityId) From e6e468d85c45070c799516aa549d6b100e079681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20G=C3=A4rtner?= Date: Tue, 25 Oct 2022 09:26:28 +0300 Subject: [PATCH 3/3] Update create-tokens.py --- create-tokens.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create-tokens.py b/create-tokens.py index 1a0db04..2421518 100644 --- a/create-tokens.py +++ b/create-tokens.py @@ -113,8 +113,8 @@ def create_tokens(ds, **kwargs): AND active = true AND approved = true AND token_id IS NULL - LIMIT .format(mintLimit) - """.format(entityId)) + LIMIT {} + """.format(entityId, mintLimit)) trees = cursor.fetchall() print('Trees found', len(trees))