Skip to content

Commit

Permalink
refactor: lookup the collection related to mint_random in another query
Browse files Browse the repository at this point in the history
  • Loading branch information
kespinola committed Oct 11, 2023
1 parent 2631187 commit ed9fe24
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions api/src/mutations/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,20 +1159,18 @@ 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)
.one(conn)
.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;
Expand Down

0 comments on commit ed9fe24

Please sign in to comment.