summaryrefslogtreecommitdiffstats
path: root/src/http/routes/mod.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
committeraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
commit3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch)
tree7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /src/http/routes/mod.rs
parent9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff)
downloadaur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.tar.gz
aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.zip
rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off
rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three.
Diffstat (limited to 'src/http/routes/mod.rs')
-rw-r--r--src/http/routes/mod.rs50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs
index 2b9ebb9..1affabf 100644
--- a/src/http/routes/mod.rs
+++ b/src/http/routes/mod.rs
@@ -1,21 +1,27 @@
-use crate::db::{self, builds, model::*};
-use crate::review::candidates;
-use crate::time;
use super::auth;
-use super::render::*;
+use super::render::{
+ Attention, Audit, AuditRow, BlockedRow, BuildDetail, BuildLite, BuildRow, Builds, BuildsTable, Dashboard,
+ ErrorPage, IndexRow, Login, NoticeRow, PackageDetail, Packages, Page, Panel, PublishRow, ReviewDetail, ReviewHead,
+ ReviewRow, ReviewsPage, SettingRow, Settings, StaleRow, StepRow, SubRow, Subscriptions, TimelineRow, UnbuiltRow,
+};
use super::{Req, Res, State};
+use crate::db::{
+ self, builds,
+ model::{candidate_kind, BuildState, CandidateRow, Recipe, StepState, SubscriptionState},
+};
+use crate::review::candidates;
+use crate::time;
mod mutations;
mod pages;
pub(crate) use mutations::{
- build_cancel, build_retry, notice_ack, package_rebuild, package_withdraw, review_approve,
- review_reject, reviews_bulk, sub_add, sub_pause, sub_remove,
+ build_cancel, build_retry, notice_ack, package_rebuild, package_withdraw, review_approve, review_reject,
+ reviews_bulk, sub_add, sub_pause, sub_remove,
};
pub(crate) use pages::{
- attention, audit, build_detail, build_log, build_log_stream, builds_page, builds_with,
- dashboard, metrics, package_detail, packages, panels_base, review_body, review_detail,
- review_rows, reviews, settings, subscriptions,
+ attention, audit, build_detail, build_log, build_log_stream, builds_page, builds_with, dashboard, metrics,
+ package_detail, packages, panels_base, review_body, review_detail, review_rows, reviews, settings, subscriptions,
};
pub(crate) fn gate(state: &State, req: &Req, sid: &str) -> Option<Res> {
@@ -64,9 +70,8 @@ fn login_impl(state: &State, req: &Req) -> Res {
if let Some(old) = req.cookie("sid") {
auth::drop_session(&old);
}
- let sid = match auth::new_session() {
- Some(sid) => sid,
- None => return page_to_res(Login { page, error: "server: no entropy for a session".into() }, 500),
+ let Some(sid) = auth::new_session() else {
+ return page_to_res(Login { page, error: "server: no entropy for a session".into() }, 500);
};
auth::authenticate(&sid);
let mut res = Res::redirect("/");
@@ -111,25 +116,16 @@ pub(crate) fn route(state: &State, req: &Req, seg: &[&str]) -> Res {
fn not_found(state: &State, req: &Req) -> Res {
let page = chrome(state, req, "Not found", "nav_packages");
- page_to_res(
- ErrorPage {
- page,
- status: "404".into(),
- message: "no such page".into(),
- detail: String::new(),
- },
- 404,
- )
+ page_to_res(ErrorPage { page, status: "404".into(), message: "no such page".into(), detail: String::new() }, 404)
}
fn chrome(state: &State, req: &Req, title: &str, active: &str) -> Page {
let db = &state.db;
let mut page = Page::new(title, csrf(state, req));
- page.pending = candidates::pending_candidates(db).map(|v| v.len() as i64).unwrap_or(0);
- page.running = builds::in_flight(db).map(|v| v as i64).unwrap_or(0)
- + builds::queue_depth(db).map(|v| v as i64).unwrap_or(0);
- page.attention = db::list_notices(db, false).map(|v| v.len() as i64).unwrap_or(0)
- + builds::blocked_builds(db).map(|v| v.len() as i64).unwrap_or(0);
+ page.pending = candidates::pending_candidates(db).map_or(0, |v| v.len() as i64);
+ page.running = builds::in_flight(db).map_or(0, |v| v as i64) + builds::queue_depth(db).map_or(0, |v| v as i64);
+ page.attention = db::list_notices(db, false).map_or(0, |v| v.len() as i64)
+ + builds::blocked_builds(db).map_or(0, |v| v.len() as i64);
page.nav_reviews = if active == "nav_reviews" { "on" } else { "" };
page.nav_builds = if active == "nav_builds" { "on" } else { "" };
page.nav_attention = if active == "nav_attention" { "on" } else { "" };
@@ -142,7 +138,7 @@ fn chrome(state: &State, req: &Req, title: &str, active: &str) -> Page {
}
fn csrf(_state: &State, req: &Req) -> String {
- req.cookie("sid").map(|s| auth::csrf_token(&s)).unwrap_or_default()
+ req.cookie("sid").map_or_default(|s| auth::csrf_token(&s))
}
fn human_size(bytes: i64) -> String {