diff options
Diffstat (limited to 'src/db/models/artifact.rs')
-rw-r--r-- | src/db/models/artifact.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/db/models/artifact.rs b/src/db/models/artifact.rs index 01de301..01ac4c7 100644 --- a/src/db/models/artifact.rs +++ b/src/db/models/artifact.rs @@ -15,6 +15,7 @@ use anyhow::anyhow; use anyhow::Error; use anyhow::Context; use anyhow::Result; +use chrono::NaiveDateTime; use diesel::PgConnection; use diesel::prelude::*; @@ -27,7 +28,6 @@ use crate::schema::artifacts; pub struct Artifact { pub id: i32, pub path: String, - pub released: bool, pub job_id: i32, } @@ -35,7 +35,6 @@ pub struct Artifact { #[table_name="artifacts"] struct NewArtifact<'a> { pub path: &'a str, - pub released: bool, pub job_id: i32, } @@ -44,13 +43,16 @@ impl Artifact { PathBuf::from(&self.path) } - pub fn create(database_connection: &PgConnection, art_path: &ArtifactPath, art_released: bool, job: &Job) -> Result<Artifact> { + pub fn released(self, database_connection: &PgConnection, release_date: &NaiveDateTime) -> Result<crate::db::models::Release> { + crate::db::models::Release::create(database_connection, &self, release_date) + } + + pub fn create(database_connection: &PgConnection, art_path: &ArtifactPath, job: &Job) -> Result<Artifact> { let path_str = art_path.to_str() .ok_or_else(|| anyhow!("Path is not valid UTF-8: {}", art_path.display())) .context("Writing artifact to database")?; let new_art = NewArtifact { path: path_str, - released: art_released, job_id: job.id, }; |