From ed9fe243d502675e3c174bd5ae5331799dadc318 Mon Sep 17 00:00:00 2001 From: Kyle Espinola Date: Wed, 11 Oct 2023 22:39:37 +0200 Subject: [PATCH] refactor: lookup the collection related to mint_random in another query --- api/src/mutations/mint.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/api/src/mutations/mint.rs b/api/src/mutations/mint.rs index 7af2012..2ecbafb 100644 --- a/api/src/mutations/mint.rs +++ b/api/src/mutations/mint.rs @@ -1159,12 +1159,7 @@ impl Mutation { .await? .ok_or(Error::new("drop not found"))?; - let (mint, collection) = CollectionMints::find() - .join( - JoinType::InnerJoin, - collection_mints::Relation::Collections.def(), - ) - .select_also(collections::Entity) + let mint = CollectionMints::find() .filter(collection_mints::Column::CollectionId.eq(drop.collection_id)) .filter(collection_mints::Column::CreationStatus.eq(CreationStatus::Queued)) .order_by(SimpleExpr::FunctionCall(Func::random()), Order::Asc) @@ -1172,7 +1167,10 @@ impl Mutation { .await? .ok_or(Error::new("No Queued mint found for the drop"))?; - let collection = collection.ok_or(Error::new("collection not found"))?; + let collection = collections::Entity::find_by_id(drop.collection_id) + .one(conn) + .await? + .ok_or(Error::new("collection not found"))?; let project_id = collection.project_id; let blockchain = collection.blockchain;