summaryrefslogtreecommitdiffstats
path: root/rust/src/api_helpers.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-07-20 20:00:39 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-07-20 20:00:39 -0700
commit634720bbd2a967a4b2a60c215a63070eabd4db06 (patch)
tree4e2a86dde2869810ffff27eb7905e80dc7f05595 /rust/src/api_helpers.rs
parent313f6926a6608e9740924e3ff4fe6dfea2016397 (diff)
downloadfatcat-634720bbd2a967a4b2a60c215a63070eabd4db06.tar.gz
fatcat-634720bbd2a967a4b2a60c215a63070eabd4db06.zip
editor_id and editgroup_id as idents; revisions as raw UUID
Diffstat (limited to 'rust/src/api_helpers.rs')
-rw-r--r--rust/src/api_helpers.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/rust/src/api_helpers.rs b/rust/src/api_helpers.rs
index 1ee08c76..14d3dd5e 100644
--- a/rust/src/api_helpers.rs
+++ b/rust/src/api_helpers.rs
@@ -6,7 +6,7 @@ use diesel::prelude::*;
use errors::*;
use uuid::Uuid;
-pub fn get_or_create_editgroup(editor_id: i64, conn: &PgConnection) -> Result<i64> {
+pub fn get_or_create_editgroup(editor_id: Uuid, conn: &PgConnection) -> 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 {
@@ -25,7 +25,7 @@ pub fn get_or_create_editgroup(editor_id: i64, conn: &PgConnection) -> Result<i6
})
}
-pub fn accept_editgroup(editgroup_id: i64, conn: &PgConnection) -> Result<ChangelogRow> {
+pub fn accept_editgroup(editgroup_id: Uuid, conn: &PgConnection) -> Result<ChangelogRow> {
conn.build_transaction().run(|| {
// check that we haven't accepted already (in changelog)
// NB: could leave this to a UNIQUE constraint
@@ -34,7 +34,10 @@ pub fn accept_editgroup(editgroup_id: i64, conn: &PgConnection) -> Result<Change
.count()
.get_result(conn)?;
if count > 0 {
- bail!("editgroup {} has already been accepted", editgroup_id);
+ bail!(
+ "editgroup {} has already been accepted",
+ editgroup_id.to_string()
+ );
}
// for each entity type...
@@ -69,7 +72,7 @@ pub fn accept_editgroup(editgroup_id: i64, conn: &PgConnection) -> Result<Change
{entity}_ident.id = {entity}_edit.ident_id
AND {entity}_edit.editgroup_id = $1",
entity = entity
- )).bind::<diesel::sql_types::BigInt, _>(editgroup_id)
+ )).bind::<diesel::sql_types::Uuid, _>(editgroup_id)
.execute(conn)?;
}
@@ -79,7 +82,7 @@ pub fn accept_editgroup(editgroup_id: i64, conn: &PgConnection) -> Result<Change
.get_result(conn)?;
// update any editor's active editgroup
- let no_active: Option<i64> = None;
+ let no_active: Option<Uuid> = None;
diesel::update(editor::table)
.filter(editor::active_editgroup_id.eq(editgroup_id))
.set(editor::active_editgroup_id.eq(no_active))