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

Import from Donation Backup Service #1253

Merged
merged 14 commits into from
Jan 23, 2024

Conversation

aminlatifi
Copy link
Member

@aminlatifi aminlatifi commented Jan 18, 2024

@aminlatifi aminlatifi marked this pull request as draft January 18, 2024 17:00
@CarlosQ96 CarlosQ96 force-pushed the donation-save-backup-import branch 7 times, most recently from f103a88 to 05b63ff Compare January 21, 2024 05:35
@CarlosQ96 CarlosQ96 force-pushed the donation-save-backup-import branch from 05b63ff to afca023 Compare January 21, 2024 05:45
@aminlatifi aminlatifi marked this pull request as ready for review January 22, 2024 07:33
@aminlatifi aminlatifi marked this pull request as draft January 22, 2024 08:57
Comment on lines +77 to +78
logger.error(`donation error with id ${donation._id}: `, e);
logger.error('donation error with params: ', donation);
Copy link
Member Author

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.

Copy link
Collaborator

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

Copy link
Member Author

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.

Copy link
Collaborator

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

Copy link
Collaborator

@CarlosQ96 CarlosQ96 Jan 23, 2024

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.

Comment on lines 81 to 86
skip += limit;
donations =
await getDonationSaveBackupAdapter().getNotImportedDonationsFromBackup({
limit,
skip,
});
Copy link
Member Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point

@CarlosQ96 CarlosQ96 marked this pull request as ready for review January 23, 2024 05:02
Copy link
Collaborator

@CarlosQ96 CarlosQ96 left a 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.

@mohammadranjbarz mohammadranjbarz merged commit de14c4b into staging Jan 23, 2024
3 checks passed
@mohammadranjbarz mohammadranjbarz deleted the donation-save-backup-import branch January 23, 2024 08:24
mohammadranjbarz added a commit that referenced this pull request Jan 23, 2024
* 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]>
mohammadranjbarz added a commit that referenced this pull request Jan 31, 2024
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants