From 576f7fadc1ab948f2776c4803a49dc8d68c05bff Mon Sep 17 00:00:00 2001 From: "Dusan Mijatovic (PC2020)" Date: Thu, 24 Oct 2024 16:50:53 +0200 Subject: [PATCH] fix: use rpc mentions_by_software for software mentions counts. We count unique entries per software and mention id. --- database/100-create-api-views.sql | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/database/100-create-api-views.sql b/database/100-create-api-views.sql index 8299c2913..ccfa7f80c 100644 --- a/database/100-create-api-views.sql +++ b/database/100-create-api-views.sql @@ -749,6 +749,7 @@ $$; -- TOTAL COUNTS FOR HOMEPAGE -- software_cnt, project_cnt, organisation_cnt -- this rpc returns json object instead of array +-- DEPENDS on RPC mentions_by_software (104-software-views.sql) CREATE FUNCTION homepage_counts( OUT software_cnt BIGINT, OUT open_software_cnt BIGINT, @@ -759,18 +760,18 @@ CREATE FUNCTION homepage_counts( ) LANGUAGE plpgsql STABLE AS $$ BEGIN - SELECT COUNT(id) FROM software INTO software_cnt; - SELECT COUNT(id) FROM software WHERE NOT closed_source INTO open_software_cnt; - SELECT COUNT(id) FROM project INTO project_cnt; + SELECT COUNT(*) FROM software INTO software_cnt; + SELECT COUNT(*) FROM software WHERE NOT closed_source INTO open_software_cnt; + SELECT COUNT(*) FROM project INTO project_cnt; SELECT - COUNT(id) AS organisation_cnt + COUNT(*) AS organisation_cnt FROM organisations_overview(TRUE) WHERE organisations_overview.parent IS NULL AND organisations_overview.score>0 INTO organisation_cnt; SELECT COUNT(DISTINCT(orcid,given_names,family_names)) FROM contributor INTO contributor_cnt; - SELECT COUNT(mention) FROM mention_for_software INTO software_mention_cnt; + SELECT COUNT(*) FROM mentions_by_software() INTO software_mention_cnt; END $$;