-
Notifications
You must be signed in to change notification settings - Fork 4
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
Faucet Referral Codes #30
base: main
Are you sure you want to change the base?
Conversation
db.prepare( | ||
`CREATE INDEX IF NOT EXISTS operator_index ON ${TABLE.TRANSACTIONS} (${TRANSACTIONS_TABLE.WALLET}, ${TRANSACTIONS_TABLE.TIMESTAMP}) WHERE ${TRANSACTIONS_TABLE.WALLET} IS NOT NULL;` | ||
).run(); | ||
|
||
db.prepare( | ||
`CREATE INDEX IF NOT EXISTS operator_index ON ${TABLE.TRANSACTIONS} (${TRANSACTIONS_TABLE.TARGET}, ${TRANSACTIONS_TABLE.TIMESTAMP}, ${TRANSACTIONS_TABLE.CODE}) WHERE ${TRANSACTIONS_TABLE.CODE} IS NOT NULL;` | ||
).run(); |
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.
you've got two use 2 different names, otherwise the second one is never created!
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.
maybe operator_target ?
.prepare<string>( | ||
`SELECT ${CODE_TABLE.ID}, ${CODE_TABLE.WALLET}, ${CODE_TABLE.DRIP}, ${CODE_TABLE.MAXUSES} FROM ${TABLE.CODE} WHERE ${CODE_TABLE.ID} = ?` | ||
) | ||
.all(code)[0] as CodeDetails; |
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.
why not use
https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#getbindparameters---row
when you need one item at most and not all the rows?
); | ||
} | ||
|
||
const { wallet, maxuses, drip: codeDrip } = getReferralCodeDetails({ db, code }); |
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.
maxUses?
codeTransactionHistory.filter((transaction) => transaction.target === targetAddress) | ||
.length >= 1 |
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.
codeTransactionHistory.filter((transaction) => transaction.target === targetAddress) | |
.length >= 1 | |
codeTransactionHistory.some((transaction) => transaction.target === targetAddress) |
Reverts #29