Indefero

Indefero Commit Details


Date:2009-06-19 14:10:37 (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:d6c0b7a6802c9e5d5ae6fd9cccc51a1b1ce8f1cd
Parents: 25e296fbb63cb487943d11ad5308b923516f4aaa
Message:Added forge size statistics.

Changes:

File differences

src/IDF/Views/Admin.php
6464
6565
6666
67
6768
6869
6970
71
7072
7173
7274
......
7476
7577
7678
79
7780
7881
7982
......
283286
284287
285288
286
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
$list_display = array(
'shortname' => __('Short Name'),
'name' => __('Name'),
array('id', 'IDF_Views_Admin_projectSize', __('Repository Size')),
);
$pag->configure($list_display, array(),
array('shortname'));
$pag->extra_classes = array('', '', 'right');
$pag->items_per_page = 25;
$pag->no_results_text = __('No projects were found.');
$pag->setFromRequest($request);
array(
'page_title' => $title,
'projects' => $pag,
'size' => IDF_Views_Admin_getForgeSize(),
),
$request);
}
$img = ($item->$field) ? 'day' : 'night';
$text = ($item->$field) ? __('Yes') : __('No');
return sprintf('<img src="'.Pluf::f('url_media').'/idf/img/%s.png" alt="%s" /> ', $img, $text);
}
}
/**
* Display the size of the project.
*
* @param string Field
* @param IDF_Project
* @return string
*/
function IDF_Views_Admin_projectSize($field, $project)
{
$size = $project->getRepositorySize();
if ($size == -1) {
return '';
}
return Pluf_Utils::prettySize($size);
}
/**
* Get a forge size.
*
* @return array Associative array with the size of each element
*/
function IDF_Views_Admin_getForgeSize()
{
$res = array();
$res['repositories'] = 0;
foreach (Pluf::factory('IDF_Project')->getList() as $prj) {
$size = $prj->getRepositorySize();
if ($size != -1) {
$res['repositories'] += $size;
}
}
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs '
.escapeshellarg(Pluf::f('upload_path'));
$out = split(' ', shell_exec($cmd), 2);
$res['downloads'] = $out[0];
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs '
.escapeshellarg(Pluf::f('upload_issue_path'));
$out = split(' ', shell_exec($cmd), 2);
$res['attachments'] = $out[0];
$res['total'] = $res['repositories'] + $res['downloads'] + $res['attachments'];
// TODO: now we need the db
return $res;
}
/**
* Get the database size as given by the database.
*
* @return int Database size
*/
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
}
src/IDF/templates/idf/gadmin/projects/index.html
11
22
3
3
44
55
66
77
88
9
10
11
12
13
14
15
16
17
18
19
20
21
{extends "idf/gadmin/projects/base.html"}
{block docclass}yui-t2{assign $inIndex=true}{/block}
{block docclass}yui-t3{assign $inIndex=true}{/block}
{block body}
{$projects.render}
{/block}
{block context}
<div class="issue-submit-info">
<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>
</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.08333s using 13 queries.