diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-11-10 08:40:24 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-11-10 09:04:43 +0100 |
commit | acb656ae19ab6361149d75ab35f8b6db16d718ce (patch) | |
tree | c13f616d4dcb55b52c3910f6b1f2d6c127e2d59c /src/db/models | |
parent | 451b417f547c9c58a66847bf472e82664c87460b (diff) |
Change Tree implementation to be a Vec<_>
This patch changes the implementation of the Tree type to be a
Vec<(Package, Tree)> internally.
This is needed because we need to be able to serialize the tree into a
JSON document later, which we want to store in the database.
Because a `Package` is not a `String`, which is what is required for a
key in JSON, we cannot use `BTreeMap<Package, Tree>` for the Tree
implementation.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Fixes: d9f6c396808b5cbee18ca2f37e4eb82df215d5fd ("Fix: Do not actually write package tree into database")
Diffstat (limited to 'src/db/models')
-rw-r--r-- | src/db/models/submit.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/db/models/submit.rs b/src/db/models/submit.rs index 1f81584..e5b3849 100644 --- a/src/db/models/submit.rs +++ b/src/db/models/submit.rs @@ -1,3 +1,4 @@ +use anyhow::anyhow; use anyhow::Context; use anyhow::Error; use anyhow::Result; @@ -35,7 +36,7 @@ struct NewSubmit<'a> { impl Submit { pub fn create(database_connection: &PgConnection, - _t: &crate::package::Tree, + t: &crate::package::Tree, submit_datetime: &NaiveDateTime, submit_id: &::uuid::Uuid, requested_image: &Image, @@ -43,10 +44,9 @@ impl Submit { repo_hash: &GitHash) -> Result<Submit> { - //let tree_json = serde_json::to_value(t) - // .context("Converting tree to JSON string") - // .with_context(|| anyhow!("Tree = {:#?}", t))?; - let tree_json = serde_json::Value::default(); // TODO: Fixme + let tree_json = serde_json::to_value(t) + .context("Converting tree to JSON string") + .with_context(|| anyhow!("Tree = {:#?}", t))?; let new_submit = NewSubmit { uuid: submit_id, |