From 9bb1b10d10cd2b1863c9e5f136621a845b0cb3c1 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 11 Jan 2019 11:59:02 -0800 Subject: WIP on annotations and editgroup accessors --- rust/src/database_models.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'rust/src/database_models.rs') diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs index 4e83afdb..ef6eb65d 100644 --- a/rust/src/database_models.rs +++ b/rust/src/database_models.rs @@ -4,7 +4,7 @@ use crate::database_schema::*; use crate::errors::*; use crate::identifiers::uuid2fcid; use chrono; -use fatcat_api_spec::models::{ChangelogEntry, Editgroup, Editor, EntityEdit}; +use fatcat_api_spec::models::{ChangelogEntry, Editgroup, EditgroupAnnotation, Editor, EntityEdit}; use serde_json; use uuid::Uuid; @@ -556,8 +556,8 @@ pub struct EditgroupRow { pub created: chrono::NaiveDateTime, pub submitted: Option, pub is_accepted: bool, - pub extra_json: Option, pub description: Option, + pub extra_json: Option, } impl EditgroupRow { @@ -578,6 +578,30 @@ impl EditgroupRow { } } +#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)] +#[table_name = "editgroup_annotation"] +pub struct EditgroupAnnotationRow { + pub id: Uuid, + pub editgroup_id: Uuid, + pub editor_id: Uuid, + pub created: chrono::NaiveDateTime, + pub comment_markdown: Option, + pub extra_json: Option, +} + +impl EditgroupAnnotationRow { + pub fn into_model(self) -> EditgroupAnnotation { + EditgroupAnnotation { + annotation_id: Some(self.id.to_string()), + editgroup_id: Some(uuid2fcid(&self.editgroup_id)), + editor_id: Some(uuid2fcid(&self.editor_id)), + created: Some(chrono::DateTime::from_utc(self.created, chrono::Utc)), + comment_markdown: self.comment_markdown, + extra: self.extra_json, + } + } +} + #[derive(Debug, Clone, Queryable, Identifiable, Associations, AsChangeset)] #[table_name = "editor"] pub struct EditorRow { -- cgit v1.2.3