-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure about this one though... syntax might be wrong There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to test it fully, I remember this syntax for variables: @CareyAltgilbers can you also help on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asarephilip there it is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dadiorchen Yes, I'll be happy to take a look at it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello, It looks like on line 61 kwards is a typo and should be kwargs. In the SQL statement on line 116 we should be able to change LIMIT .format(mintLimit) to Limit {} and then on line 117 change that to """.format(entityId, mintLimit)) That gives us two unnamed variables in this SQL statement, one on line 110 in a function call and another in line 116. I ran the code in a test script and did not get any syntax errors, if you have some test data I can use for the entityId and mintLimit I would run the test script again. cursor.execute(""" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed it. Should be fine now. see new change request |
||
""".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 | ||
|
There was a problem hiding this comment.
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 whenminLimit
isNone
.There was a problem hiding this comment.
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