From 8a130e1000a2b49cbfb571ae0b74f0ec8577e9fe Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 14 May 2019 18:43:07 -0700 Subject: codegen and rust impl created timestamp --- rust/src/database_models.rs | 7 ++++++- rust/src/endpoint_handlers.rs | 4 +++- rust/src/entity_crud.rs | 17 +++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'rust/src') diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs index 34ce1de6..79b0137b 100644 --- a/rust/src/database_models.rs +++ b/rust/src/database_models.rs @@ -662,12 +662,17 @@ pub struct EditgroupRow { impl EditgroupRow { /// Returns an Editgroup API model *without* the entity edits actually populated. Useful for, /// eg, entity history queries (where we already have the entity edit we want) - pub fn into_model_partial(self, changelog_index: Option, editor: Option) -> Editgroup { + pub fn into_model_partial( + self, + changelog_index: Option, + editor: Option, + ) -> Editgroup { Editgroup { editgroup_id: Some(uuid2fcid(&self.id)), editor_id: Some(uuid2fcid(&self.editor_id)), editor: editor, changelog_index: changelog_index, + created: Some(chrono::DateTime::from_utc(self.created, chrono::Utc)), submitted: self .submitted .map(|v| chrono::DateTime::from_utc(v, chrono::Utc)), diff --git a/rust/src/endpoint_handlers.rs b/rust/src/endpoint_handlers.rs index ba8505e1..5c22e21d 100644 --- a/rust/src/endpoint_handlers.rs +++ b/rust/src/endpoint_handlers.rs @@ -558,7 +558,9 @@ impl Server { .into_iter() .map(|(eg_row, cl_row, editor_row)| ChangelogEntry { index: cl_row.id, - editgroup: Some(eg_row.into_model_partial(Some(cl_row.id), Some(editor_row.into_model()))), + editgroup: Some( + eg_row.into_model_partial(Some(cl_row.id), Some(editor_row.into_model())), + ), editgroup_id: uuid2fcid(&cl_row.editgroup_id), timestamp: chrono::DateTime::from_utc(cl_row.timestamp, chrono::Utc), }) diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs index 269bfdf6..b72ccd37 100644 --- a/rust/src/entity_crud.rs +++ b/rust/src/entity_crud.rs @@ -538,14 +538,15 @@ macro_rules! generic_db_get_history { ) -> Result> { let limit = limit.unwrap_or(50); // TODO: make a static - let rows: Vec<(EditgroupRow, ChangelogRow, Self::EditRow, EditorRow)> = editgroup::table - .inner_join(changelog::table) - .inner_join($edit_table::table) - .inner_join(editor::table) - .filter($edit_table::ident_id.eq(ident.to_uuid())) - .order(changelog::id.desc()) - .limit(limit) - .get_results(conn)?; + let rows: Vec<(EditgroupRow, ChangelogRow, Self::EditRow, EditorRow)> = + editgroup::table + .inner_join(changelog::table) + .inner_join($edit_table::table) + .inner_join(editor::table) + .filter($edit_table::ident_id.eq(ident.to_uuid())) + .order(changelog::id.desc()) + .limit(limit) + .get_results(conn)?; let history: Result> = rows .into_iter() -- cgit v1.2.3