Skip to content

Commit

Permalink
Merge pull request #252 from holaplex/release
Browse files Browse the repository at this point in the history
Backfill Release - 10/11
  • Loading branch information
kespinola authored Oct 18, 2023
2 parents 9fdb8fd + 69246eb commit 7082d89
Show file tree
Hide file tree
Showing 3 changed files with 36 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 @@ -1173,20 +1173,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
2 changes: 2 additions & 0 deletions migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ mod m20230911_144938_make_compressed_column_optional;
mod m20230914_154759_add_job_trackings_table;
mod m20230915_111128_create_mints_creation_status_idx;
mod m20230922_150621_nullable_metadata_jsons_identifier_and_uri;
mod m20231011_202917_create_queued_mints_idx;

pub struct Migrator;

Expand Down Expand Up @@ -127,6 +128,7 @@ impl MigratorTrait for Migrator {
Box::new(m20230915_111128_create_mints_creation_status_idx::Migration),
Box::new(m20230914_154759_add_job_trackings_table::Migration),
Box::new(m20230922_150621_nullable_metadata_jsons_identifier_and_uri::Migration),
Box::new(m20231011_202917_create_queued_mints_idx::Migration),
]
}
}
29 changes: 29 additions & 0 deletions migration/src/m20231011_202917_create_queued_mints_idx.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use sea_orm_migration::{
prelude::*,
sea_orm::{ConnectionTrait, Statement},
};

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let db = manager.get_connection();

let stmt = Statement::from_string(
manager.get_database_backend(),
r#"CREATE INDEX IF NOT EXISTS queued_mints_idx ON collection_mints(creation_status)
where creation_status = 'queued';"#
.to_string(),
);

db.execute(stmt).await?;

Ok(())
}

async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
Ok(())
}
}

0 comments on commit 7082d89

Please sign in to comment.