Commit 619d46a5 authored by Andrew Robert Nicols's avatar Andrew Robert Nicols
Browse files

Ensure ordering of unused views and improve performance of query.



Unused views weren't being sorted so I've opted to sort them by view title
alphabetically.

I also notice that the query was using a subselect so I've changed this to
a join to improve efficiency of the query.
Signed-off-by: default avatarAndrew Robert Nicols <andrew.nicols@luns.net.uk>
parent ec8fd70d
......@@ -275,12 +275,13 @@ class Collection {
$userid = $USER->get('id');
($views = get_records_sql_array("SELECT v.id, v.title
FROM {view} v
WHERE v.owner = ? AND v.type NOT IN ('dashboard','grouphomepage','profile')
AND v.id NOT IN (
SELECT cv.view
FROM {collection_view} cv
)
GROUP BY v.id, v.title", array($userid)))
LEFT JOIN {collection_view} cv ON cv.view = v.id
WHERE v.owner = ?
AND cv.view IS NULL
AND v.type NOT IN ('dashboard','grouphomepage','profile')
GROUP BY v.id, v.title
ORDER BY v.title ASC
", array($userid)))
|| ($views = array());
return $views;
......
Markdown is supported
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