Skip to content

Instantly share code, notes, and snippets.

@ragingcomputer
Created January 12, 2017 22:21
Show Gist options
  • Save ragingcomputer/a80184d0f5b98c365c59309e4e4d1716 to your computer and use it in GitHub Desktop.
Save ragingcomputer/a80184d0f5b98c365c59309e4e4d1716 to your computer and use it in GitHub Desktop.
SQL query for Moodle to show space usage in User Private Backup Area by user
SELECT CONCAT(mu.firstname, ' ', mu.lastname, ' (', mu.email, ')' ) AS Teacher,
ROUND((SUM(mf.filesize)/1024)/1024, 2) AS Storage_Used_MB
FROM mdl_files AS mf
LEFT JOIN mdl_user AS mu ON mf.userid = mu.id
WHERE mf.component = 'user'
AND mf.filearea = 'backup'
AND NOT mf.filename = '.'
GROUP BY mf.contextid
ORDER BY Storage_Used_MB DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment