diff --git a/Repositories/statistics/includes/inc.class.mysql.es.php b/Repositories/statistics/includes/inc.class.mysql.es.php index 7dfdb8d..f2fd00b 100755 --- a/Repositories/statistics/includes/inc.class.mysql.es.php +++ b/Repositories/statistics/includes/inc.class.mysql.es.php @@ -184,6 +184,26 @@ $limit = $this->buildWhereClause( $where_parts, 'AND' ); +/* +A possible optimisation? One query to get all abstracts & downloads, which +eliminates the need for the merge_countries function. Below takes about the +same time as the two original queries. + +select country_code, country_name, max(country_downloads), max(country_abstracts) +from ( + select case view_type when view_type = 'abstract' then count(*) else 0 end as country_abstracts, + case view_type when view_type = 'download' then count(*) else 0 end as country_downloads, + view_type, + country_name, + country_code + from view + where archive_name = 'otago_eprints' + group by country_name, view_type +) as inside +group by country_code, country_name +order by country_downloads desc, country_name; +*/ + // Create a result array $records = array(); //Build up the query