From 2fccfc3563dfb2e7e4e7bb871c7c989647a6e850 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Wed, 20 Mar 2024 17:43:17 +0800 Subject: [PATCH] feat: extend auto refresh timeout to 30s, fix pagination --- frontend/src/pages/pipelines/index.vue | 4 ++-- server/src/routes/pipeline.rs | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/pipelines/index.vue b/frontend/src/pages/pipelines/index.vue index a30271c..5c80699 100644 --- a/frontend/src/pages/pipelines/index.vue +++ b/frontend/src/pages/pipelines/index.vue @@ -33,7 +33,7 @@ { if (this.countdown == 0) { clearInterval(this.intervalHandle); diff --git a/server/src/routes/pipeline.rs b/server/src/routes/pipeline.rs index 4d626b9..1427f18 100644 --- a/server/src/routes/pipeline.rs +++ b/server/src/routes/pipeline.rs @@ -175,10 +175,21 @@ pub async fn pipeline_list( Ok(Json( conn.transaction::(|conn| { - let total_items = crate::schema::pipelines::dsl::pipelines - .count() - .get_result(conn)?; + // compute total items for pagination + let mut total_items_query = crate::schema::pipelines::dsl::pipelines.into_boxed(); + if query.stable_only { + total_items_query = total_items_query + .filter(crate::schema::pipelines::dsl::git_branch.eq("stable")); + } + if query.github_pr_only { + total_items_query = total_items_query + .filter(crate::schema::pipelines::dsl::github_pr.is_not_null()); + } + + let total_items = total_items_query.count().get_result(conn)?; + + // collect pipelines let mut sql = crate::schema::pipelines::dsl::pipelines .left_join(crate::schema::users::dsl::users) .order_by(crate::schema::pipelines::dsl::id.desc())