Skip to content

Commit 2104454

Browse files
committed
Turn NextArtifact into an enum
1 parent 7e8d765 commit 2104454

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

collector/src/api.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
pub mod next_artifact {
2-
use database::ArtifactId;
2+
use database::Commit;
33

44
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
5-
pub struct NextArtifact {
6-
pub artifact: ArtifactId,
7-
pub include: Option<String>,
8-
pub exclude: Option<String>,
9-
pub runs: Option<i32>,
5+
pub enum NextArtifact {
6+
Release(String),
7+
Commit {
8+
commit: Commit,
9+
include: Option<String>,
10+
exclude: Option<String>,
11+
runs: Option<i32>,
12+
},
1013
}
1114

1215
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]

collector/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,14 +1013,11 @@ fn main_result() -> anyhow::Result<i32> {
10131013
let pool = database::Pool::open(&db.db);
10141014

10151015
match next {
1016-
NextArtifact {
1017-
artifact: ArtifactId::Tag(tag),
1018-
..
1019-
} => {
1016+
NextArtifact::Release(tag) => {
10201017
bench_published_artifact(tag, pool, &mut rt, &target_triple, &benchmark_dir)?;
10211018
}
1022-
NextArtifact {
1023-
artifact: ArtifactId::Commit(commit),
1019+
NextArtifact::Commit {
1020+
commit,
10241021
include,
10251022
exclude,
10261023
runs,

site/src/request_handlers/next_artifact.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::load::{MissingReason, SiteCtxt};
22
use collector::api::next_artifact;
33

4-
use database::ArtifactId;
54
use std::sync::Arc;
65

76
pub async fn handle_next_artifact(ctxt: Arc<SiteCtxt>) -> next_artifact::Response {
@@ -11,12 +10,7 @@ pub async fn handle_next_artifact(ctxt: Arc<SiteCtxt>) -> next_artifact::Respons
1110
if let Some(next_artifact) = next_artifact.into_iter().next() {
1211
log::debug!("next_artifact: {next_artifact}");
1312
return next_artifact::Response {
14-
artifact: Some(next_artifact::NextArtifact {
15-
artifact: ArtifactId::Tag(next_artifact),
16-
exclude: None,
17-
include: None,
18-
runs: None,
19-
}),
13+
artifact: Some(next_artifact::NextArtifact::Release(next_artifact)),
2014
};
2115
}
2216
}
@@ -71,8 +65,8 @@ pub async fn handle_next_artifact(ctxt: Arc<SiteCtxt>) -> next_artifact::Respons
7165
commit.sha,
7266
missing_reason_dbg
7367
);
74-
Some(next_artifact::NextArtifact {
75-
artifact: ArtifactId::Commit(commit),
68+
Some(next_artifact::NextArtifact::Commit {
69+
commit,
7670
include,
7771
exclude,
7872
runs,

0 commit comments

Comments
 (0)