summaryrefslogtreecommitdiffstats
path: root/src/http/routes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/routes.rs')
-rw-r--r--src/http/routes.rs76
1 files changed, 57 insertions, 19 deletions
diff --git a/src/http/routes.rs b/src/http/routes.rs
index 784024d..ab68069 100644
--- a/src/http/routes.rs
+++ b/src/http/routes.rs
@@ -4,7 +4,7 @@
//! connection โ€” and hands mutations to the writer actor. A slow client can
//! therefore never hold the write lock, which is the whole point of the split.
-use crate::db::{self, builds, model::*};
+use crate::db::{self, builds, model::*, Db};
use crate::review::{approve as ap, candidates, diff, risk};
use crate::{pipeline, time};
@@ -592,15 +592,19 @@ fn attention(state: &State, req: &Req) -> Res {
.iter()
.filter(|s| s.kind == crate::watch::staleness::Kind::Outdated)
.cloned()
- .map(|s| StaleRow { pkgbase: s.pkgbase, built_with: s.built_with, now: s.now })
+ .map(|s| StaleRow { pkgbase: s.pkgbase, dependency: s.dependency, built_with: s.built_with, now: s.now })
.collect();
let missing: Vec<StaleRow> = stale
.iter()
.filter(|s| s.kind == crate::watch::staleness::Kind::Missing)
.cloned()
- .map(|s| StaleRow { pkgbase: s.pkgbase, built_with: s.built_with, now: s.now })
+ .map(|s| StaleRow { pkgbase: s.pkgbase, dependency: s.dependency, built_with: s.built_with, now: s.now })
+ .collect();
+ let downgrades: Vec<StaleRow> = crate::watch::staleness::downgrades(db)
+ .unwrap_or_default()
+ .into_iter()
+ .map(|s| StaleRow { pkgbase: s.pkgbase, dependency: s.dependency, built_with: s.built_with, now: s.now })
.collect();
- let downgrades: Vec<StaleRow> = Vec::new();
let empty = notices.is_empty() && outdated.is_empty() && missing.is_empty() && blocked.is_empty();
page_to_res(
Attention { page, empty, notices, outdated, missing, downgrades, blocked },
@@ -687,6 +691,19 @@ fn package_detail(state: &State, req: &Req, name: &str) -> Res {
step: b.current_step.unwrap_or_default(),
})
.collect();
+ // Depends-on comes from the recipe we actually serve; needed-by comes from
+ // the packages whose own recipes name this one (ยง10.3).
+ let deps_in: Vec<String> = accepted
+ .as_ref()
+ .and_then(|r| db::accepted_recipe(db, r).ok().flatten())
+ .map(|r| {
+ let mut v = crate::pkgver::dep_names(&r.depends);
+ v.sort();
+ v.dedup();
+ v
+ })
+ .unwrap_or_default();
+ let deps_out: Vec<String> = crate::watch::staleness::dependents_of(db, name).unwrap_or_default();
let stale: Vec<String> = crate::watch::staleness::stale_for(db, name)
.unwrap_or_default()
.into_iter()
@@ -703,8 +720,8 @@ fn package_detail(state: &State, req: &Req, name: &str) -> Res {
summary,
can_withdraw: accepted.is_some(),
stale,
- deps_in: Vec::new(),
- deps_out: Vec::new(),
+ deps_in,
+ deps_out,
timeline,
builds,
},
@@ -746,6 +763,22 @@ fn package_withdraw(state: &State, req: &Req, name: &str) -> Res {
// --------------------------------------------------------------- builds --
+/// The version a build is about. A build points at a candidate, or โ€” for a
+/// manual rebuild of something already published โ€” at a release.
+fn build_version(db: &Db, b: &builds::BuildRow) -> String {
+ if let Some(cid) = b.candidate_id {
+ if let Some(c) = candidates::candidate_by_id(db, cid).ok().flatten() {
+ return c.version();
+ }
+ }
+ if let Some(rid) = b.release_id {
+ if let Some(r) = db::release_by_id(db, rid).ok().flatten() {
+ return r.version();
+ }
+ }
+ String::new()
+}
+
fn build_rows(state: &State) -> Vec<BuildRow> {
builds::list(
&state.db,
@@ -760,11 +793,12 @@ fn build_rows(state: &State) -> Vec<BuildRow> {
.flatten()
.map(|p| p.name)
.unwrap_or_default();
+ let version = build_version(&state.db, &b);
BuildRow {
id_short: short(&b.id),
id: b.id,
pkgbase,
- version: String::new(),
+ version,
kind: b.kind,
state: b.state,
step: b.current_step.unwrap_or_default(),
@@ -785,17 +819,21 @@ fn builds_with(state: &State, _req: &Req, page: Page) -> Res {
let recent: Vec<BuildRow> = builds::list(&state.db, &[build_state::FAILED, build_state::SUCCEEDED], 10)
.unwrap_or_default()
.into_iter()
- .map(|b| BuildRow {
- id_short: short(&b.id),
- id: b.id,
- pkgbase: db::get_pkgbase_by_id(&state.db, b.pkgbase_id).ok().flatten().map(|p| p.name).unwrap_or_default(),
- version: String::new(),
- kind: b.kind,
- state: b.state,
- step: b.current_step.unwrap_or_default(),
- lease: String::new(),
- cancel: b.cancel_requested,
- error: b.error.unwrap_or_default(),
+ .map(|b| {
+ let pkgbase = db::get_pkgbase_by_id(&state.db, b.pkgbase_id).ok().flatten().map(|p| p.name).unwrap_or_default();
+ let version = build_version(&state.db, &b);
+ BuildRow {
+ id_short: short(&b.id),
+ id: b.id,
+ pkgbase,
+ version,
+ kind: b.kind,
+ state: b.state,
+ step: b.current_step.unwrap_or_default(),
+ lease: String::new(),
+ cancel: b.cancel_requested,
+ error: b.error.unwrap_or_default(),
+ }
})
.collect();
page_to_res(Builds { page, rows: build_rows(state), recent }, 200)
@@ -834,7 +872,7 @@ fn build_detail(state: &State, req: &Req, id: &str) -> Res {
id: id.to_string(),
id_short: short(id),
pkgbase,
- version: String::new(),
+ version: build_version(db, &b),
kind: b.kind,
state: b.state,
error: b.error.clone().unwrap_or_default(),