Indefero

Indefero Commit Details


Date:2009-06-19 15:42:44 (15 years 6 months ago)
Author:Loic d'Anterroches
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:0873d4416232e2170b29f8897a2cc23b5b55ac28
Parents: 6cf4f00f92205e0749e5c007b8a039e8f75c767b
Message:Added the database usage statistics.

Changes:

File differences

src/IDF/Views/Admin.php
327327
328328
329329
330
331
330
331
332332
333333
334334
......
339339
340340
341341
342
343
344
345
346
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
347374
.escapeshellarg(Pluf::f('upload_issue_path'));
$out = split(' ', shell_exec($cmd), 2);
$res['attachments'] = $out[0]*1024;
$res['total'] = $res['repositories'] + $res['downloads'] + $res['attachments'];
// TODO: now we need the db
$res['database'] = IDF_Views_Admin_getForgeDbSize();
$res['total'] = $res['repositories'] + $res['downloads'] + $res['attachments'] + $res['database'];
return $res;
}
*/
function IDF_Views_Admin_getForgeDbSize()
{
// MySQL: SHOW TABLE STATUS FROM database;
// then sum Data_length and Index_length for each table
// PostgreSQL:
// Directly stats the database file
$db = Pluf::db();
if (Pluf::f('db_engine') == 'SQLite') {
return filesize(Pluf::f('db_database'));
}
switch (Pluf::f('db_engine')) {
case 'PostgreSQL':
$sql = 'SELECT relname, pg_total_relation_size(relname) AS size FROM pg_class AS pgc, pg_namespace AS pgn
WHERE pg_table_is_visible(pgc.oid) IS TRUE AND relkind = \'r\'
AND pgc.relnamespace = pgn.oid
AND pgn.nspname NOT IN (\'information_schema\', \'pg_catalog\')';
break;
case 'MySQL':
default:
$sql = 'SHOW TABLE STATUS FROM '.Pluf::f('db_database');
break;
}
$rs = $db->select($sql);
$total = 0;
switch (Pluf::f('db_engine')) {
case 'PostgreSQL':
foreach ($rs as $table) {
$total += $table['size'];
}
break;
case 'MySQL':
default:
foreach ($rs as $table) {
$total += $table['Data_length'] + $table['Index_length'];
}
break;
}
return $total;
}
src/IDF/templates/idf/gadmin/projects/index.html
88
99
1010
11
1112
12
13
14
15
13
14
15
16
17
1618
17
19
1820
1921
2022
{block context}
<div class="issue-submit-info">
<p><strong>{trans 'Space Usage Statistics'}</strong></p>
<ul>
<li>{trans 'Repository size:'} {$size['repositories']|size}</li>
<li>{trans 'Attachment size:'} {$size['attachments']|size}</li>
<li>{trans 'Download size:'} {$size['downloads']|size}</li>
<li>{trans 'Forge size:'} {$size['total']|size}</li>
<li>{trans 'Repositories:'} {$size['repositories']|size}</li>
<li>{trans 'Attachments:'} {$size['attachments']|size}</li>
<li>{trans 'Downloads:'} {$size['downloads']|size}</li>
<li>{trans 'Database:'} {$size['database']|size}</li>
<li><strong>{trans 'Total Forge:'} {$size['total']|size}</strong></li>
</ul>
<p>{trans 'The forge size does not include the database space yet.'}</p>
</div>
{/block}

Archive Download the corresponding diff file

Page rendered in 0.08119s using 13 queries.