perf: 优化 dashboard 的查询性能 (#393)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-07-12 16:06:16 +08:00
committed by GitHub
parent 87fb597ba4
commit 29d78dabdd
3 changed files with 54 additions and 26 deletions

View File

@@ -7,6 +7,7 @@ mod m20240724_161008_submission;
mod m20250122_062926_add_latest_row_at;
mod m20250612_090826_add_enabled;
mod m20250613_043257_add_config;
mod m20250712_080013_add_video_created_at_index;
pub struct Migrator;
@@ -21,6 +22,7 @@ impl MigratorTrait for Migrator {
Box::new(m20250122_062926_add_latest_row_at::Migration),
Box::new(m20250612_090826_add_enabled::Migration),
Box::new(m20250613_043257_add_config::Migration),
Box::new(m20250712_080013_add_video_created_at_index::Migration),
]
}
}

View File

@@ -0,0 +1,36 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_index(
Index::create()
.table(Video::Table)
.name("video_created_at_index")
.col(Video::CreatedAt)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_index(
Index::drop()
.table(Video::Table)
.name("video_created_at_index")
.to_owned(),
)
.await
}
}
#[derive(DeriveIden)]
enum Video {
Table,
CreatedAt,
}