Skip to content

Commit

Permalink
Merge pull request #250 from holaplex/espi/mint-random-query
Browse files Browse the repository at this point in the history
Query optimizing for mint random
  • Loading branch information
kespinola authored Oct 11, 2023
2 parents 2631187 + ed9fe24 commit 6593d73
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 6593d73

Please sign in to comment.