From 34839845429e066b5c44a19fba95711b14c196e2 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 24 Dec 2018 16:24:32 -0800 Subject: remove unused postgres-backed stats stuff Will replace with elasticsearch-based dash in webface --- rust/src/api_server.rs | 84 +++--------------------------------------------- rust/src/api_wrappers.rs | 19 ----------- 2 files changed, 5 insertions(+), 98 deletions(-) (limited to 'rust/src') 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 { + pub fn get_editgroup_handler( + &self, + editgroup_id: FatCatId, + conn: &DbConn, + ) -> Result { 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, conn: &DbConn) -> Result { - 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 = 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 = 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, - _context: &Context, - ) -> Box + 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))) - } } -- cgit v1.2.3