-
Notifications
You must be signed in to change notification settings - Fork 18
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
Import from Donation Backup Service #1253
Conversation
f103a88
to
05b63ff
Compare
05b63ff
to
afca023
Compare
logger.error(`donation error with id ${donation._id}: `, e); | ||
logger.error('donation error with params: ', donation); |
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.
There is a point here, if importing an item gets an error, it will be fetched in the next round of importing again. So, it will endlessly be processed in each iteration.
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.
@aminlatifi
How about adding another field(like isImported) for this kind of donations and set it true in this case, and not get them again
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.
The name can be importError
I think to hold the error message as well. Before going for that, we must be sure this importing is a deterministic process. I mean, if it fails here, it will fail every next time we try. If it holds, that would be ok to mark the items got error in importing and ignore them, but if not we must allow them to be processed in next iteration.
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.
Cool , I will do it
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 see the skip was removed. Could simply add a counter that increases when it enters the catch() statement. And on each iteration reset it to 0. And skip based on that number.
But at the same time we could simply increase the limit and let the process run every hour or so. It shouldn't be a heavy process.
I was checking failed donations, and even on the previous round where we had big errors, the amount is never a huge number.
skip += limit; | ||
donations = | ||
await getDonationSaveBackupAdapter().getNotImportedDonationsFromBackup({ | ||
limit, | ||
skip, | ||
}); |
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.
There is a serious issue here, the items we import above, will not match the query filter any more (their imported field will have true value). So, we shouldn't increase the skip value here naively, just increase by number of items which we got error in processing above.
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.
Good point
Reuse donation resolver
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.
Thanks Mohammad, those are the changes I was wanted. Better error handling, interfaces and mocks.
I think we should probably merge, check there isn't any issue in staging.
* Verify transfer spl-token on solana, supporting multi chain solana related to #1175 * fix solana tests on devnet * add solana additional tokens * fix solana token transfer test * improve joi schema chaintype validator * Add another spl-token transfer test case, change validator of createDonation webservice related to #1232 (comment) * Refactor and change a nested if-else with witch case * Removed only tags from tests * Update src/utils/errorMessages.ts Co-authored-by: Amin Latifi <[email protected]> * Update src/utils/locales/en.json Co-authored-by: Amin Latifi <[email protected]> * Fill networkId for solana addresses when create/update projects * Add some test tokens for solana dev chain * Import lost donations into DB cronjob (#1236) * import donations from env vars and add tests * Read LOST_DONATIONS_TX_HASHES from .env instead of config * Fix build error --------- Co-authored-by: Amin Latifi <[email protected]> Co-authored-by: Mohammad Ranjbar Z <[email protected]> * setup notification center disabling and reduce notifications * Change filling networkId for solana * Fix migration files for adding spl tokens on solana * Modify create donation test cases for check filling networkId of solana donations * comment out notification center methods interface * Revert "comment out notification center methods interface" This reverts commit 4a6dd8c. * set logic as before, comment notification center methods not required * move donation received logic to notification adapter * Refactor get networkId for solana addresses and implement getAppropriateNetworkId * Fix filling solana donations price (#1252) * Fix filling solana donations price related to Giveth/giveth-dapps-v2#3394 (comment) * Add informative logs for filling value usd part * Add log for createDonation webservice * change type of transactionNetworkId to number in ajv schema * Update createDonation to use correct networkId * Added jobId to donation verification queue * fix test env * Import from Donation Backup Service (#1253) * Added Donation Save Backup Adapter * add backup service import cronjob * add interface of used params from mongo data * Change loading urls for backup service * Refactor donationSaveBackupAdapter and adding mock adapter * Removed unused package script * Refactored createBackupDonation to reuse resolver * Fix createBackupDonation() and write test case for that * Add importError to failed donation mongo backup --------- Co-authored-by: mohammadranjbarz <[email protected]> Co-authored-by: Carlos <[email protected]> * Fix query of getting failed donations from mongo API * Add more logs for importing failed donations * Change info logs to debug logs * 1.21.0 * Add importDate to donation entity * Fill importDate of donation correctly --------- Co-authored-by: Mohammad Ranjbar Z <[email protected]> Co-authored-by: Carlos <[email protected]> Co-authored-by: CarlosQ96 <[email protected]>
* Verify transfer spl-token on solana, supporting multi chain solana related to #1175 * fix solana tests on devnet * add solana additional tokens * fix solana token transfer test * improve joi schema chaintype validator * Add another spl-token transfer test case, change validator of createDonation webservice related to #1232 (comment) * Refactor and change a nested if-else with witch case * Removed only tags from tests * Update src/utils/errorMessages.ts Co-authored-by: Amin Latifi <[email protected]> * Update src/utils/locales/en.json Co-authored-by: Amin Latifi <[email protected]> * Fill networkId for solana addresses when create/update projects * Add some test tokens for solana dev chain * Import lost donations into DB cronjob (#1236) * import donations from env vars and add tests * Read LOST_DONATIONS_TX_HASHES from .env instead of config * Fix build error --------- Co-authored-by: Amin Latifi <[email protected]> Co-authored-by: Mohammad Ranjbar Z <[email protected]> * setup notification center disabling and reduce notifications * Change filling networkId for solana * Fix migration files for adding spl tokens on solana * Modify create donation test cases for check filling networkId of solana donations * comment out notification center methods interface * Revert "comment out notification center methods interface" This reverts commit 4a6dd8c. * set logic as before, comment notification center methods not required * move donation received logic to notification adapter * Refactor get networkId for solana addresses and implement getAppropriateNetworkId * Fix filling solana donations price (#1252) * Fix filling solana donations price related to Giveth/giveth-dapps-v2#3394 (comment) * Add informative logs for filling value usd part * Add log for createDonation webservice * change type of transactionNetworkId to number in ajv schema * Update createDonation to use correct networkId * Added jobId to donation verification queue * fix test env * Import from Donation Backup Service (#1253) * Added Donation Save Backup Adapter * add backup service import cronjob * add interface of used params from mongo data * Change loading urls for backup service * Refactor donationSaveBackupAdapter and adding mock adapter * Removed unused package script * Refactored createBackupDonation to reuse resolver * Fix createBackupDonation() and write test case for that * Add importError to failed donation mongo backup --------- Co-authored-by: mohammadranjbarz <[email protected]> Co-authored-by: Carlos <[email protected]> * Fix query of getting failed donations from mongo API * Add more logs for importing failed donations * Change info logs to debug logs * 1.21.0 * Add importDate to donation entity * Fill importDate of donation correctly * Put importing failed donations in try...catch * Added back jobId to verifyDonationsQueue, along with removeOnComplete and removeOnFail --------- Co-authored-by: Mohammad Ranjbar Z <[email protected]> Co-authored-by: Carlos <[email protected]> Co-authored-by: CarlosQ96 <[email protected]>
#1247