summaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-09 13:06:11 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-09 13:06:11 -0800
commitad58e900247ca9be2b29ea8f926c4120e1c9501a (patch)
tree68b0f59daf1a1b66b1bd4061ef13c076f106a81e /rust/src
parentcbf615dda68367600c47c6867d27737c0113ca39 (diff)
downloadfatcat-ad58e900247ca9be2b29ea8f926c4120e1c9501a.tar.gz
fatcat-ad58e900247ca9be2b29ea8f926c4120e1c9501a.zip
start removing active editgroup code
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/database_models.rs1
-rw-r--r--rust/src/database_schema.rs2
-rw-r--r--rust/src/editing.rs21
3 files changed, 4 insertions, 20 deletions
diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs
index 4575aeaf..0b6de130 100644
--- a/rust/src/database_models.rs
+++ b/rust/src/database_models.rs
@@ -584,7 +584,6 @@ pub struct EditorRow {
pub registered: chrono::NaiveDateTime,
pub auth_epoch: chrono::NaiveDateTime,
pub wrangler_id: Option<Uuid>,
- pub active_editgroup_id: Option<Uuid>,
}
impl EditorRow {
diff --git a/rust/src/database_schema.rs b/rust/src/database_schema.rs
index 0c553b40..ac5acec8 100644
--- a/rust/src/database_schema.rs
+++ b/rust/src/database_schema.rs
@@ -114,7 +114,6 @@ table! {
registered -> Timestamptz,
auth_epoch -> Timestamptz,
wrangler_id -> Nullable<Uuid>,
- active_editgroup_id -> Nullable<Uuid>,
}
}
@@ -406,6 +405,7 @@ joinable!(container_edit -> editgroup (editgroup_id));
joinable!(container_ident -> container_rev (rev_id));
joinable!(creator_edit -> editgroup (editgroup_id));
joinable!(creator_ident -> creator_rev (rev_id));
+joinable!(editgroup -> editor (editor_id));
joinable!(file_edit -> editgroup (editgroup_id));
joinable!(file_ident -> file_rev (rev_id));
joinable!(file_rev_release -> file_rev (file_rev));
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)
}