diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-11 17:47:52 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-11 17:47:52 -0800 |
commit | 2ee844b75c611ae32f40f1d65dcb00f3de553240 (patch) | |
tree | 0a763b7fd60ab9c463748fe5294b8b14c7ad4911 /rust/src/editing_crud.rs | |
parent | 21a932b6412cfa9610d3d40c95b34be6e52a97ce (diff) | |
download | fatcat-2ee844b75c611ae32f40f1d65dcb00f3de553240.tar.gz fatcat-2ee844b75c611ae32f40f1d65dcb00f3de553240.zip |
cleanups and TODOs
Diffstat (limited to 'rust/src/editing_crud.rs')
-rw-r--r-- | rust/src/editing_crud.rs | 174 |
1 files changed, 76 insertions, 98 deletions
diff --git a/rust/src/editing_crud.rs b/rust/src/editing_crud.rs index 65403eee..9d6477a5 100644 --- a/rust/src/editing_crud.rs +++ b/rust/src/editing_crud.rs @@ -140,32 +140,26 @@ impl EditgroupCrud for Editgroup { before: Option<chrono::DateTime<chrono::Utc>>, ) -> Result<Vec<(EditgroupRow, Option<ChangelogRow>)>> { let rows: Vec<(EditgroupRow, Option<ChangelogRow>)> = match (since, before) { - (Some(since), None) => { - editgroup::table - .left_outer_join(changelog::table) - .filter(editgroup::editor_id.eq(editor_id.to_uuid())) - .filter(editgroup::created.gt(since)) - .order_by(editgroup::created.asc()) - .limit(limit as i64) - .get_results(conn)? - }, - (_, Some(before)) => { - editgroup::table - .left_outer_join(changelog::table) - .filter(editgroup::editor_id.eq(editor_id.to_uuid())) - .filter(editgroup::created.lt(before)) - .order_by(editgroup::created.desc()) - .limit(limit as i64) - .get_results(conn)? - }, - (None, None) => { - editgroup::table - .left_outer_join(changelog::table) - .filter(editgroup::editor_id.eq(editor_id.to_uuid())) - .order_by(editgroup::created.desc()) - .limit(limit as i64) - .get_results(conn)? - }, + (Some(since), None) => editgroup::table + .left_outer_join(changelog::table) + .filter(editgroup::editor_id.eq(editor_id.to_uuid())) + .filter(editgroup::created.gt(since)) + .order_by(editgroup::created.asc()) + .limit(limit as i64) + .get_results(conn)?, + (_, Some(before)) => editgroup::table + .left_outer_join(changelog::table) + .filter(editgroup::editor_id.eq(editor_id.to_uuid())) + .filter(editgroup::created.lt(before)) + .order_by(editgroup::created.desc()) + .limit(limit as i64) + .get_results(conn)?, + (None, None) => editgroup::table + .left_outer_join(changelog::table) + .filter(editgroup::editor_id.eq(editor_id.to_uuid())) + .order_by(editgroup::created.desc()) + .limit(limit as i64) + .get_results(conn)?, }; Ok(rows) } @@ -177,32 +171,26 @@ impl EditgroupCrud for Editgroup { before: Option<chrono::DateTime<chrono::Utc>>, ) -> Result<Vec<EditgroupRow>> { let rows: Vec<EditgroupRow> = match (since, before) { - (Some(since), None) => { - editgroup::table - .filter(editgroup::is_accepted.eq(false)) - .filter(editgroup::submitted.is_not_null()) - .filter(editgroup::submitted.gt(since)) - .order_by(editgroup::submitted.asc()) - .limit(limit as i64) - .get_results(conn)? - }, - (_, Some(before)) => { - editgroup::table - .filter(editgroup::is_accepted.eq(false)) - .filter(editgroup::submitted.is_not_null()) - .filter(editgroup::submitted.lt(before)) - .order_by(editgroup::submitted.desc()) - .limit(limit as i64) - .get_results(conn)? - }, - (None, None) => { - editgroup::table - .filter(editgroup::is_accepted.eq(false)) - .filter(editgroup::submitted.is_not_null()) - .order_by(editgroup::created.desc()) - .limit(limit as i64) - .get_results(conn)? - }, + (Some(since), None) => editgroup::table + .filter(editgroup::is_accepted.eq(false)) + .filter(editgroup::submitted.is_not_null()) + .filter(editgroup::submitted.gt(since)) + .order_by(editgroup::submitted.asc()) + .limit(limit as i64) + .get_results(conn)?, + (_, Some(before)) => editgroup::table + .filter(editgroup::is_accepted.eq(false)) + .filter(editgroup::submitted.is_not_null()) + .filter(editgroup::submitted.lt(before)) + .order_by(editgroup::submitted.desc()) + .limit(limit as i64) + .get_results(conn)?, + (None, None) => editgroup::table + .filter(editgroup::is_accepted.eq(false)) + .filter(editgroup::submitted.is_not_null()) + .order_by(editgroup::created.desc()) + .limit(limit as i64) + .get_results(conn)?, }; Ok(rows) } @@ -315,29 +303,23 @@ impl EditgroupAnnotationCrud for EditgroupAnnotation { before: Option<chrono::DateTime<chrono::Utc>>, ) -> Result<Vec<EditgroupAnnotationRow>> { let rows: Vec<EditgroupAnnotationRow> = match (since, before) { - (Some(since), None) => { - editgroup_annotation::table - .filter(editgroup_annotation::editor_id.eq(editor_id.to_uuid())) - .filter(editgroup_annotation::created.gt(since)) - .order_by(editgroup_annotation::created.asc()) - .limit(limit as i64) - .get_results(conn)? - }, - (_, Some(before)) => { - editgroup_annotation::table - .filter(editgroup_annotation::editor_id.eq(editor_id.to_uuid())) - .filter(editgroup_annotation::created.lt(before)) - .order_by(editgroup_annotation::created.desc()) - .limit(limit as i64) - .get_results(conn)? - }, - (None, None) => { - editgroup_annotation::table - .filter(editgroup_annotation::editor_id.eq(editor_id.to_uuid())) - .order_by(editgroup_annotation::created.desc()) - .limit(limit as i64) - .get_results(conn)? - }, + (Some(since), None) => editgroup_annotation::table + .filter(editgroup_annotation::editor_id.eq(editor_id.to_uuid())) + .filter(editgroup_annotation::created.gt(since)) + .order_by(editgroup_annotation::created.asc()) + .limit(limit as i64) + .get_results(conn)?, + (_, Some(before)) => editgroup_annotation::table + .filter(editgroup_annotation::editor_id.eq(editor_id.to_uuid())) + .filter(editgroup_annotation::created.lt(before)) + .order_by(editgroup_annotation::created.desc()) + .limit(limit as i64) + .get_results(conn)?, + (None, None) => editgroup_annotation::table + .filter(editgroup_annotation::editor_id.eq(editor_id.to_uuid())) + .order_by(editgroup_annotation::created.desc()) + .limit(limit as i64) + .get_results(conn)?, }; Ok(rows) } @@ -350,29 +332,23 @@ impl EditgroupAnnotationCrud for EditgroupAnnotation { before: Option<chrono::DateTime<chrono::Utc>>, ) -> Result<Vec<EditgroupAnnotationRow>> { let rows: Vec<EditgroupAnnotationRow> = match (since, before) { - (Some(since), None) => { - editgroup_annotation::table - .filter(editgroup_annotation::editgroup_id.eq(editgroup_id.to_uuid())) - .filter(editgroup_annotation::created.gt(since)) - .order_by(editgroup_annotation::created.asc()) - .limit(limit as i64) - .get_results(conn)? - }, - (_, Some(before)) => { - editgroup_annotation::table - .filter(editgroup_annotation::editgroup_id.eq(editgroup_id.to_uuid())) - .filter(editgroup_annotation::created.lt(before)) - .order_by(editgroup_annotation::created.desc()) - .limit(limit as i64) - .get_results(conn)? - }, - (None, None) => { - editgroup_annotation::table - .filter(editgroup_annotation::editgroup_id.eq(editgroup_id.to_uuid())) - .order_by(editgroup_annotation::created.desc()) - .limit(limit as i64) - .get_results(conn)? - }, + (Some(since), None) => editgroup_annotation::table + .filter(editgroup_annotation::editgroup_id.eq(editgroup_id.to_uuid())) + .filter(editgroup_annotation::created.gt(since)) + .order_by(editgroup_annotation::created.asc()) + .limit(limit as i64) + .get_results(conn)?, + (_, Some(before)) => editgroup_annotation::table + .filter(editgroup_annotation::editgroup_id.eq(editgroup_id.to_uuid())) + .filter(editgroup_annotation::created.lt(before)) + .order_by(editgroup_annotation::created.desc()) + .limit(limit as i64) + .get_results(conn)?, + (None, None) => editgroup_annotation::table + .filter(editgroup_annotation::editgroup_id.eq(editgroup_id.to_uuid())) + .order_by(editgroup_annotation::created.desc()) + .limit(limit as i64) + .get_results(conn)?, }; Ok(rows) } @@ -392,6 +368,8 @@ impl EditgroupAnnotationCrud for EditgroupAnnotation { .values(( editgroup_annotation::editor_id.eq(editor_id.to_uuid()), editgroup_annotation::editgroup_id.eq(editgroup_id.to_uuid()), + editgroup_annotation::comment_markdown.eq(&self.comment_markdown), + editgroup_annotation::extra_json.eq(&self.extra), )) .get_result(conn)?; Ok(ed) |