aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-09-11 13:59:45 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-09-11 13:59:45 -0700
commit1603ce316f1e611bf82b959b6d9b2ada1e769c32 (patch)
tree927289223873db8d4bdf711984b4313adc393f65 /rust
parentcd8e09fcb6ee0a1b23c0bd57d0f097f99fd6d828 (diff)
downloadfatcat-1603ce316f1e611bf82b959b6d9b2ada1e769c32.tar.gz
fatcat-1603ce316f1e611bf82b959b6d9b2ada1e769c32.zip
new rustfmt
Diffstat (limited to 'rust')
-rw-r--r--rust/src/api_entity_crud.rs23
-rw-r--r--rust/src/api_server.rs38
2 files changed, 35 insertions, 26 deletions
diff --git a/rust/src/api_entity_crud.rs b/rust/src/api_entity_crud.rs
index 4d5caf62..0fb1c690 100644
--- a/rust/src/api_entity_crud.rs
+++ b/rust/src/api_entity_crud.rs
@@ -255,7 +255,8 @@ macro_rules! generic_db_get_history {
.limit(limit)
.get_results(conn)?;
- let history: Result<Vec<EntityHistoryEntry>> = rows.into_iter()
+ let history: Result<Vec<EntityHistoryEntry>> = rows
+ .into_iter()
.map(|(eg_row, cl_row, e_row)| {
Ok(EntityHistoryEntry {
edit: e_row.into_model()?,
@@ -804,7 +805,8 @@ impl EntityCrud for ReleaseEntity {
year: r.year,
title: r.title,
locator: r.locator,
- target_release_id: r.target_release_ident_id
+ target_release_id: r
+ .target_release_ident_id
.map(|v| FatCatId::from_uuid(&v).to_string()),
})
.collect();
@@ -822,7 +824,8 @@ impl EntityCrud for ReleaseEntity {
raw_name: c.raw_name,
role: c.role,
extra: c.extra_json,
- creator_id: c.creator_ident_id
+ creator_id: c
+ .creator_ident_id
.map(|v| FatCatId::from_uuid(&v).to_string()),
creator: None,
})
@@ -897,10 +900,11 @@ impl EntityCrud for ReleaseEntity {
}
let rev_ids: Vec<Uuid> = insert_into(release_rev::table)
- .values(models
- .iter()
- .map(|model| {
- Ok(ReleaseRevNewRow {
+ .values(
+ models
+ .iter()
+ .map(|model| {
+ Ok(ReleaseRevNewRow {
title: model.title.clone(),
release_type: model.release_type.clone(),
release_status: model.release_status.clone(),
@@ -926,8 +930,9 @@ impl EntityCrud for ReleaseEntity {
language: model.language.clone(),
extra_json: model.extra.clone()
})
- })
- .collect::<Result<Vec<ReleaseRevNewRow>>>()?)
+ })
+ .collect::<Result<Vec<ReleaseRevNewRow>>>()?,
+ )
.returning(release_rev::id)
.get_results(conn)?;
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 449196be..978f9893 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -408,29 +408,33 @@ impl Server {
let files_with_releases: Option<i64> = if more.is_some() {
// this query is slightly inaccurate and over-counts: it includes files that have release
// links only to inactive releases
- Some(file_rev::table
- .inner_join(file_ident::table)
- .inner_join(file_release::table)
- .filter(file_ident::is_live.eq(true))
- .filter(file_ident::redirect_id.is_null())
- .select(file_ident::id)
- .distinct()
- .count()
- .first(conn)?)
+ Some(
+ file_rev::table
+ .inner_join(file_ident::table)
+ .inner_join(file_release::table)
+ .filter(file_ident::is_live.eq(true))
+ .filter(file_ident::redirect_id.is_null())
+ .select(file_ident::id)
+ .distinct()
+ .count()
+ .first(conn)?,
+ )
} else {
None
};
let releases_with_files: Option<i64> = if more.is_some() {
// this slightly overcounts also: it will include releases which are only linked to from
// inactive files
- Some(release_ident::table
- .inner_join(file_release::table)
- .filter(release_ident::is_live.eq(true))
- .filter(release_ident::redirect_id.is_null())
- .select(file_release::target_release_ident_id)
- .distinct()
- .count()
- .first(conn)?)
+ Some(
+ release_ident::table
+ .inner_join(file_release::table)
+ .filter(release_ident::is_live.eq(true))
+ .filter(release_ident::redirect_id.is_null())
+ .select(file_release::target_release_ident_id)
+ .distinct()
+ .count()
+ .first(conn)?,
+ )
} else {
None
};