aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/database_models.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-11 11:59:02 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-11 11:59:02 -0800
commit9bb1b10d10cd2b1863c9e5f136621a845b0cb3c1 (patch)
tree1c013fe09934ba2666be354ed7a139c065ebd52e /rust/src/database_models.rs
parent22c85fa299438b64e65c422b677c0c97fc2b5ef6 (diff)
downloadfatcat-9bb1b10d10cd2b1863c9e5f136621a845b0cb3c1.tar.gz
fatcat-9bb1b10d10cd2b1863c9e5f136621a845b0cb3c1.zip
WIP on annotations and editgroup accessors
Diffstat (limited to 'rust/src/database_models.rs')
-rw-r--r--rust/src/database_models.rs28
1 files changed, 26 insertions, 2 deletions
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<chrono::NaiveDateTime>,
pub is_accepted: bool,
- pub extra_json: Option<serde_json::Value>,
pub description: Option<String>,
+ pub extra_json: Option<serde_json::Value>,
}
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<String>,
+ pub extra_json: Option<serde_json::Value>,
+}
+
+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 {