Skip to content
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

Index for queued mints and remove order by for random mint #251

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/src/mutations/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
};
use sea_orm::{
prelude::*,
sea_query::{Func, SimpleExpr},

Check warning on line 11 in api/src/mutations/mint.rs

View workflow job for this annotation

GitHub Actions / Cargo Test

unused imports: `Func`, `Order`, `QueryOrder`, `SimpleExpr`

Check warning on line 11 in api/src/mutations/mint.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

unused imports: `Func`, `Order`, `QueryOrder`, `SimpleExpr`

Check warning on line 11 in api/src/mutations/mint.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

unused imports: `Func`, `Order`, `QueryOrder`, `SimpleExpr`
JoinType, Order, QueryOrder, QuerySelect, Set, TransactionTrait,
};

Expand Down Expand Up @@ -1162,7 +1162,6 @@
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"))?;
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(())
}
}
Loading