Commit ea0d765a authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add blocktype counts to view stats

Signed-off-by: default avatarRichard Mansfield <>
parent 0d5ee156
......@@ -168,6 +168,7 @@ $string['statsmaxgroups'] = 'Is in %1.1f groups (most is <a href="%s">%s</a> wit
$string['statsmaxquotaused'] = 'Has used about %s of disk quota (most is <a href="%s">%s</a> with %s)';
$string['groupcountsbytype'] = 'Number of groups by Group Type';
$string['groupcountsbyjointype'] = 'Number of groups by Access Type';
$string['blockcountsbytype'] = 'Most frequently used blocks in Portfolio Views:';
// Site options
$string['adminsonly'] = 'Administrators only';
......@@ -542,6 +542,24 @@ function view_statistics($limit, $offset) {
get_string('feedback', 'view'),
$data['table'] = view_stats_table($limit, $offset);
$smarty = smarty_core();
$maxblocktypes = 5;
$smarty->assign('blocktypecounts', get_records_sql_array("
CASE WHEN bi.artefactplugin IS NULL THEN b.blocktype
ELSE bi.artefactplugin || '/' || b.blocktype END AS langsection,
COUNT( AS blocks
FROM {block_instance} b
JOIN {blocktype_installed} bi ON (b.blocktype =
JOIN {view} v ON (b.view = AND v.type = 'portfolio')
GROUP BY b.blocktype, langsection
ORDER BY blocks DESC",
array(), 0, $maxblocktypes
$data['summary'] = $smarty->fetch('admin/viewstatssummary.tpl');
return $data;
{if $blocktypecounts}
<p>{str tag=blockcountsbytype section=admin}:
{foreach from=$blocktypecounts item=item}
<li>{str tag=title section=blocktype.$item->langsection}: {$item->blocks|escape}</li>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment