-
Notifications
You must be signed in to change notification settings - Fork 47
Only update assets in mpl-core collection if auth changed #266
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
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
8c9c023
to
f9784d2
Compare
f4e639a
to
de7acc7
Compare
// If found, determine whether the authority has changed. | ||
let collection_authority_changed = match account_data { | ||
MplCoreAccountData::Collection(_) => { | ||
let existing_record = asset_authority::Entity::find() | ||
.filter(asset_authority::Column::AssetId.eq(id_vec.clone())) | ||
.one(conn) | ||
.await | ||
.map_err(|db_err| ProgramTransformerError::AssetIndexError(db_err.to_string()))?; | ||
|
||
// We need to update all assets in the collection if: | ||
// 1. The collection is found and its authority has changed. | ||
// 2. The collection is not found. | ||
// | ||
// Case 2 requires us to attempt to update all assets in a collection because assets | ||
// can be indexed before the collection itself. | ||
existing_record | ||
.map(|record| record.authority != update_authority) | ||
.unwrap_or(true) | ||
} | ||
_ => false, | ||
}; |
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 really want to avoid doing lookups while indexing. Is there a way to do this where you join in record you want to check against and then adjusting the where class of the insert or update?
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 will look into this
Notes
Prevents updating the authority for all of the assets in an mpl-core collection for every collection change.
Instead, we update all assets in the collection if:
Case 2 requires us to attempt to update all assets in a collection because assets can be indexed before the collection itself.
Testing
collection_authority_changed
condition was triggered, since collection was not yet indexed.collection_authority_changed
condition was NOT triggered for either the collection or asset.collection_authority_changed
condition was triggered and both the collection's authority and asset's authority was updated.collection_authority_changed
was NOT triggered.