aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-24 16:24:32 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-24 16:24:34 -0800
commit34839845429e066b5c44a19fba95711b14c196e2 (patch)
tree9a703a934db85a8ac0694ea10900ec702a2e82e0 /rust/src
parent8b2590b32e7b6bd2bfa518ec59c492dd48f8047f (diff)
downloadfatcat-34839845429e066b5c44a19fba95711b14c196e2.tar.gz
fatcat-34839845429e066b5c44a19fba95711b14c196e2.zip
remove unused postgres-backed stats stuff
Will replace with elasticsearch-based dash in webface
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/api_server.rs84
-rw-r--r--rust/src/api_wrappers.rs19
2 files changed, 5 insertions, 98 deletions
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 99db91c0..5b95f149 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -349,7 +349,11 @@ impl Server {
})
}
- pub fn get_editgroup_handler(&self, editgroup_id: FatCatId, conn: &DbConn) -> Result<Editgroup> {
+ pub fn get_editgroup_handler(
+ &self,
+ editgroup_id: FatCatId,
+ conn: &DbConn,
+ ) -> Result<Editgroup> {
let row: EditgroupRow = editgroup::table.find(editgroup_id.to_uuid()).first(conn)?;
let edits = EditgroupEdits {
@@ -474,84 +478,6 @@ impl Server {
Ok(entry)
}
- pub fn get_stats_handler(&self, more: &Option<String>, conn: &DbConn) -> Result<StatsResponse> {
- let merged_editgroups: i64 = changelog::table
- .select(diesel::dsl::count_star())
- .first(conn)?;
- let releases_with_dois: i64 = release_rev::table
- .inner_join(release_ident::table)
- .filter(release_rev::doi.is_not_null())
- .filter(release_ident::is_live.eq(true))
- .filter(release_ident::redirect_id.is_null())
- .select(diesel::dsl::count_star())
- .first(conn)?;
- let creators_with_orcids: i64 = creator_rev::table
- .inner_join(creator_ident::table)
- .filter(creator_rev::orcid.is_not_null())
- .filter(creator_ident::is_live.eq(true))
- .filter(creator_ident::redirect_id.is_null())
- .select(diesel::dsl::count_star())
- .first(conn)?;
- let containers_with_issnls: i64 = container_rev::table
- .inner_join(container_ident::table)
- .filter(container_rev::issnl.is_not_null())
- .filter(container_ident::is_live.eq(true))
- .filter(container_ident::redirect_id.is_null())
- .count()
- .first(conn)?;
-
- 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)?,
- )
- } 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)?,
- )
- } else {
- None
- };
-
- let val = json!({
- "entity_counts": {
- "container": count_entity!(container_ident, conn),
- "creator": count_entity!(creator_ident, conn),
- "file": count_entity!(file_ident, conn),
- "release": count_entity!(release_ident, conn),
- "work": count_entity!(work_ident, conn),
- },
- "merged_editgroups": merged_editgroups,
- "releases_with_dois": releases_with_dois,
- "creators_with_orcids": creators_with_orcids,
- "containers_with_issnls": containers_with_issnls,
- "files_with_releases": files_with_releases,
- "releases_with_files": releases_with_files,
- });
- Ok(StatsResponse { extra: Some(val) })
- }
-
entity_batch_handler!(create_container_batch_handler, ContainerEntity);
entity_batch_handler!(create_creator_batch_handler, CreatorEntity);
entity_batch_handler!(create_file_batch_handler, FileEntity);
diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs
index ed4053b9..85b698aa 100644
--- a/rust/src/api_wrappers.rs
+++ b/rust/src/api_wrappers.rs
@@ -914,23 +914,4 @@ impl Api for Server {
};
Box::new(futures::done(Ok(ret)))
}
-
- fn get_stats(
- &self,
- more: Option<String>,
- _context: &Context,
- ) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> {
- let conn = self.db_pool.get().expect("db_pool error");
- // No transaction for GET
- let ret = match self.get_stats_handler(&more, &conn) {
- Ok(stats) => GetStatsResponse::Success(stats),
- Err(e) => {
- error!("{}", e);
- GetStatsResponse::GenericError(ErrorResponse {
- message: e.to_string(),
- })
- }
- };
- Box::new(futures::done(Ok(ret)))
- }
}