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