Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a variable mintLimit #111

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions create-tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = kwargs['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')
Expand All @@ -72,7 +74,10 @@ def create_tokens(ds, **kwargs):
if dryRun is None:
print('dryRun is None')
return

if mintLimit is None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the busines logic behind this but I will recommend setting a default minLimit rather than exiting the job when minLimit is None.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

business logic works better with a limit every time. that is fine

print('mintLimit is None')
return

result = 'pending'
db = PostgresHook(postgres_conn_id='postgres_default')
connection = db.get_conn()
Expand Down Expand Up @@ -108,15 +113,15 @@ def create_tokens(ds, **kwargs):
AND active = true
AND approved = true
AND token_id IS NULL
LIMIT 3000
""".format(entityId))
LIMIT {}
""".format(entityId, mintLimit))
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
Expand Down