summaryrefslogtreecommitdiffstats
path: root/src/db/models
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-11-16 17:29:06 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-11-16 18:01:37 +0100
commit7096cbd11f7c54681750a8d66a7ad76cf3846722 (patch)
tree58689ad30d8ba4224d96dc7886149048aa4a0982 /src/db/models
parent4b92534269451282177a6631fb33fafab7003978 (diff)
Move loading of Submit object for a specific uuid to helper method
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/db/models')
-rw-r--r--src/db/models/submit.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/db/models/submit.rs b/src/db/models/submit.rs
index cfd29a3..731012a 100644
--- a/src/db/models/submit.rs
+++ b/src/db/models/submit.rs
@@ -43,7 +43,7 @@ impl Submit {
requested_package: &Package,
repo_hash: &GitHash)
-> Result<Submit>
-{
+ {
let tree_json = serde_json::to_value(t)
.context("Converting tree to JSON string")
.with_context(|| anyhow!("Tree = {:#?}", t))?;
@@ -63,11 +63,16 @@ impl Submit {
.execute(database_connection)
.context("Inserting new submit into submits table")?;
+ Self::with_id(database_connection, submit_id)
+ }
+
+ pub fn with_id(database_connection: &PgConnection, submit_id: &::uuid::Uuid) -> Result<Submit> {
dsl::submits
.filter(submits::uuid.eq(submit_id))
.first::<Submit>(database_connection)
.context("Loading submit")
.map_err(Error::from)
}
+
}