diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-09 13:06:11 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-09 13:06:11 -0800 |
commit | ad58e900247ca9be2b29ea8f926c4120e1c9501a (patch) | |
tree | 68b0f59daf1a1b66b1bd4061ef13c076f106a81e /rust/src/editing.rs | |
parent | cbf615dda68367600c47c6867d27737c0113ca39 (diff) | |
download | fatcat-ad58e900247ca9be2b29ea8f926c4120e1c9501a.tar.gz fatcat-ad58e900247ca9be2b29ea8f926c4120e1c9501a.zip |
start removing active editgroup code
Diffstat (limited to 'rust/src/editing.rs')
-rw-r--r-- | rust/src/editing.rs | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/rust/src/editing.rs b/rust/src/editing.rs index b488e489..42dd013e 100644 --- a/rust/src/editing.rs +++ b/rust/src/editing.rs @@ -45,7 +45,7 @@ pub fn make_edit_context( .get_result(conn)?; FatCatId::from_uuid(&eg_row.id) } - (None, false) => FatCatId::from_uuid(&get_or_create_editgroup(conn, editor_id.to_uuid())?), + (None, false) => FatCatId::from_uuid(&create_editgroup(conn, editor_id.to_uuid())?), }; Ok(EditContext { editor_id, @@ -86,20 +86,11 @@ pub fn update_editor_username( } /// This function should always be run within a transaction -pub fn get_or_create_editgroup(conn: &DbConn, editor_id: Uuid) -> Result<Uuid> { - // check for current active - let ed_row: EditorRow = editor::table.find(editor_id).first(conn)?; - if let Some(current) = ed_row.active_editgroup_id { - return Ok(current); - } - +pub fn create_editgroup(conn: &DbConn, editor_id: Uuid) -> Result<Uuid> { // need to insert and update let eg_row: EditgroupRow = diesel::insert_into(editgroup::table) - .values((editgroup::editor_id.eq(ed_row.id),)) + .values((editgroup::editor_id.eq(editor_id),)) .get_result(conn)?; - diesel::update(editor::table.find(ed_row.id)) - .set(editor::active_editgroup_id.eq(eg_row.id)) - .execute(conn)?; Ok(eg_row.id) } @@ -130,11 +121,5 @@ pub fn accept_editgroup(conn: &DbConn, editgroup_id: FatCatId) -> Result<Changel .values((changelog::editgroup_id.eq(editgroup_id.to_uuid()),)) .get_result(conn)?; - // update any editor's active editgroup - let no_active: Option<Uuid> = None; - diesel::update(editor::table) - .filter(editor::active_editgroup_id.eq(editgroup_id.to_uuid())) - .set(editor::active_editgroup_id.eq(no_active)) - .execute(conn)?; Ok(entry) } |