summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/candidates.rs14
-rw-r--r--src/db/invariants.rs1
-rw-r--r--src/db/migrations.rs1
-rw-r--r--src/db/model/build_state.rs4
-rw-r--r--src/db/model/state.rs28
-rw-r--r--src/db/packages.rs1
-rw-r--r--src/db/subscriptions.rs1
7 files changed, 12 insertions, 38 deletions
diff --git a/src/db/candidates.rs b/src/db/candidates.rs
index e2f011c..411d60b 100644
--- a/src/db/candidates.rs
+++ b/src/db/candidates.rs
@@ -53,7 +53,7 @@ impl NewCandidate {
}
#[derive(Debug, Clone)]
-pub struct OpenReview {
+pub(crate) struct OpenReview {
pub id: i64,
pub identity_hash: String,
pub viewed_at: Option<String>,
@@ -69,7 +69,7 @@ impl OpenReview {
// ------------------------------------------------------------------ in-tx --
#[derive(Debug, Clone)]
-pub struct ReviewSubject {
+pub(crate) struct ReviewSubject {
pub id: i64,
pub pkgbase_id: i64,
pub state: CandidateState,
@@ -78,14 +78,13 @@ pub struct ReviewSubject {
pub base_release_id: Option<i64>,
pub current_base_release_id: Option<i64>,
pub risk_level: String,
- pub pkgbase: String,
}
-pub fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Option<ReviewSubject>> {
+pub(crate) fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Option<ReviewSubject>> {
Ok(tx
.query_row(
"SELECT c.id, c.pkgbase_id, c.state, c.identity_hash, c.diff_digest, c.base_release_id,
- p.current_accepted_release_id, c.risk_level, p.name
+ p.current_accepted_release_id, c.risk_level
FROM candidate c JOIN pkgbase p ON p.id = c.pkgbase_id
WHERE c.id = ?1",
params![candidate_id],
@@ -99,7 +98,6 @@ pub fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Opti
base_release_id: r.get(5)?,
current_base_release_id: r.get(6)?,
risk_level: r.get(7)?,
- pkgbase: r.get(8)?,
})
},
)
@@ -151,7 +149,7 @@ pub fn risk_level(db: &Db, id: i64) -> Result<Option<String>> {
})
}
-pub fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenReview>> {
+pub(crate) fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenReview>> {
Ok(tx
.query_row(
"SELECT id, identity_hash, viewed_at, revision FROM candidate
@@ -169,7 +167,7 @@ pub fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenRevie
.optional()?)
}
-pub fn collapse_in(tx: &mut Transaction<'_>, open: &OpenReview, nc: &NewCandidate) -> Result<i64> {
+pub(crate) fn collapse_in(tx: &mut Transaction<'_>, open: &OpenReview, nc: &NewCandidate) -> Result<i64> {
let revision = open.revision + 1;
tx.execute(
"UPDATE candidate SET snapshot_id=?1, epoch=?2, pkgver=?3, pkgrel=?4,
diff --git a/src/db/invariants.rs b/src/db/invariants.rs
index e2648fa..e9e133f 100644
--- a/src/db/invariants.rs
+++ b/src/db/invariants.rs
@@ -31,6 +31,7 @@ pub fn unapproved_index_entries(db: &Db) -> Result<Vec<String>> {
#[derive(Debug, Clone)]
+// Unbuilt stays `pub`: the attention row `approved_but_unbuilt` returns to the web UI and to tests/crash.rs.
pub struct Unbuilt {
pub pkgbase: String,
pub approved: String,
diff --git a/src/db/migrations.rs b/src/db/migrations.rs
index 015610a..7adc69c 100644
--- a/src/db/migrations.rs
+++ b/src/db/migrations.rs
@@ -1,3 +1,4 @@
+// Migration stays `pub`: the row type of `MIGRATIONS`, which is `pub` only under `test-support`; production walks the table through `db::migrate` without naming it.
pub struct Migration {
pub version: u32,
pub name: &'static str,
diff --git a/src/db/model/build_state.rs b/src/db/model/build_state.rs
index d081bca..37eee79 100644
--- a/src/db/model/build_state.rs
+++ b/src/db/model/build_state.rs
@@ -66,7 +66,7 @@ impl BuildState {
}
}
- pub fn predecessors(to: BuildState) -> Vec<&'static str> {
+ pub(crate) fn predecessors(to: BuildState) -> Vec<&'static str> {
BuildState::ALL
.iter()
.filter(|from| from.can_transition(to))
@@ -143,7 +143,7 @@ impl StepState {
}
}
- pub fn predecessors(to: StepState) -> Vec<&'static str> {
+ pub(crate) fn predecessors(to: StepState) -> Vec<&'static str> {
StepState::ALL
.iter()
.filter(|from| from.can_transition(to))
diff --git a/src/db/model/state.rs b/src/db/model/state.rs
index dcc9b84..18860ff 100644
--- a/src/db/model/state.rs
+++ b/src/db/model/state.rs
@@ -118,20 +118,6 @@ impl ReleaseState {
pub fn parse(s: &str) -> Option<ReleaseState> {
ReleaseState::ALL.iter().copied().find(|r| r.as_str() == s)
}
-
- /// NOTE: nothing consults this table today — release transitions are
- /// enforced elsewhere. Left `pub` and dead rather than quietly deleted
- /// or quietly wired up; it is a disposition-table decision.
- pub fn can_transition(&self, to: ReleaseState) -> bool {
- use ReleaseState::*;
- if *self == to {
- return true;
- }
- match self {
- Published => matches!(to, Withdrawn | FailedUnbuilt),
- Withdrawn | FailedUnbuilt => false,
- }
- }
}
impl std::fmt::Display for ReleaseState {
@@ -199,20 +185,6 @@ impl SubscriptionState {
pub fn parse(text: &str) -> Option<SubscriptionState> {
SubscriptionState::ALL.iter().copied().find(|st| st.as_str() == text)
}
-
- /// NOTE: dead in the same way as `ReleaseState::can_transition`.
- pub fn can_transition(&self, to: SubscriptionState) -> bool {
- use SubscriptionState::*;
- if *self == to {
- return true;
- }
- match self {
- Active => matches!(to, Paused | Orphaned | Removed),
- Paused => matches!(to, Active | Orphaned | Removed),
- Orphaned => matches!(to, Active | Removed),
- Removed => false,
- }
- }
}
impl std::fmt::Display for SubscriptionState {
diff --git a/src/db/packages.rs b/src/db/packages.rs
index 0a302b0..247c328 100644
--- a/src/db/packages.rs
+++ b/src/db/packages.rs
@@ -6,6 +6,7 @@ use crate::error::Result;
// ---------------------------------------------------------------- package --
#[derive(Debug, Clone)]
+// PackageRow stays `pub`: what `index_packages` hands back to `http`, the publish step and the `aur-build` binary, which bind it without naming it.
pub struct PackageRow {
pub id: i64,
pub release_id: i64,
diff --git a/src/db/subscriptions.rs b/src/db/subscriptions.rs
index 947a205..fc17de3 100644
--- a/src/db/subscriptions.rs
+++ b/src/db/subscriptions.rs
@@ -7,6 +7,7 @@ use crate::time;
// ------------------------------------------------------------- subscriptions --
#[derive(Debug, Clone)]
+// Subscription stays `pub`: what `get_subscription` and `list_subscriptions` hand back to `watch`, `usecase`, the binary and tests/detect.rs.
pub struct Subscription {
pub id: i64,
pub pkgbase: String,