srchub-old

srchub-old Commit Details


Date:2013-08-17 14:32:00 (11 years 4 months ago)
Author:Natalie Adams
Branch:default
Commit:fce053714a1c
Parents: 4ca1e1c61211
Message:Updating public profile by writing new code that reduces queries and adds some more features - also fixes issue 13

Changes:
Mindefero/src/IDF/Commit.php (1 diff)
Mindefero/src/IDF/Issue.php (2 diffs)
Mindefero/src/IDF/Views.php (1 diff)
Mindefero/src/IDF/Views/User.php (3 diffs)
Mindefero/src/IDF/templates/idf/user/public.html (1 diff)

File differences

indefero/src/IDF/Commit.php
102102
103103
104104
105
106
107
108
109
110
111
112
105113
106114
107115
'help_text' => 'Date of creation by the scm',
),
);
$projtbl = $this->_con->pfx . "idf_projects";
$this->_a['views'] = array(
'project_find_private' => array (
'where' => 'private = 0',
'join' => "INNER JOIN " . $projtbl . " ON " . $this->getSqlTable() . ".project = " . $projtbl . ".id"
)
);
}
function __toString()
indefero/src/IDF/Issue.php
3535
3636
3737
38
3839
3940
4041
......
119120
120121
121122
123
124
125
122126
127
128
129
130
131
132
133
134
123135
124136
125137
function init()
{
//$tagtbl = "indefero_idf_tags";
$this->_a['table'] = 'idf_issues';
$this->_a['model'] = __CLASS__;
$this->_a['cols'] = array(
),
);
$table = $this->_con->pfx.'idf_issue_idf_tag_assoc';
$tagtbl = $this->_con->pfx . "idf_tags";
$projtbl = $this->_con->pfx . "idf_projects";
$this->_a['views'] = array(
'project_find' => array (
'where' => '( lcname = "new" or lcname = "accepted" or lcname = "started" )',
'join' => "INNER JOIN " . $tagtbl . " on " . $this->getSqlTable() . ".status = " . $tagtbl . ".id"
),
'project_find_private' => array (
'where' => 'private = 0 AND ( lcname = "new" or lcname = "accepted" or lcname = "started" )',
'join' => "INNER JOIN " . $tagtbl . " on " . $this->getSqlTable() . ".status = " . $tagtbl . ".id INNER JOIN " . $projtbl . " ON " . $this->getSqlTable() . ".project = " . $projtbl . ".id"
),
'join_tags' =>
array(
'join' => 'LEFT JOIN '.$table
indefero/src/IDF/Views.php
562562
563563
564564
565
565
566566
567567
568568
$forgestats[$key] = $count;
$forgestats['total'] += $count;
}
$forgestats['proj_count'] = count($projects);
$forgestats['proj_count'] = count($projects);
return $forgestats;
}
}
indefero/src/IDF/Views/User.php
7979
8080
8181
82
83
84
85
86
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
87101
88
89
90
91
92
102
103
104
93105
94
106
107
95108
96
97
98
99
100
101
102
103
104109
110
105111
106112
107
108113
109114
110115
......
281286
282287
283288
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
289303
290304
291
292
293
294
295
305
306
307
296308
297
298
299
300
301
309
302310
303311
312
304313
305314
306315
307
316
308317
309318
310319
311320
312
313
321
322
323
314324
315325
316326
......
320330
321331
322332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
323352
324353
325354
326355
327356
328357
329
358
359
360
361
330362
331363
332364
333365
334366
335367
368
369
370
371
372
373
374
375
376
336377
337378
338379
public function dashboard($request, $match, $working=true)
{
$otags = array();
// Note that this approach does not scale, we will need to add
// a table to cache the meaning of the tags for large forges.
foreach (IDF_Views::getProjects($request->user) as $project) {
$otags = array_merge($otags, $project->getTagIdsByStatus('open'));
/*
* This is a little bit better - but still not perfect
* It has a N*3 SQL query for each issue that is assigned to the user
* As long as the user isn't assigned 100+ issues - it should hold
*/
$ownedissues = Pluf::factory("IDF_Issue")->getList(array('filter' => "owner = " . $request->user->id, 'view' => 'project_find'));
$submittedissues = Pluf::factory("IDF_Issue")->getList(array('filter' => "submitter = " . $request->user->id, 'view' => 'project_find'));
$nb_owner = count($ownedissues);
$nb_submit = count($submittedissues);
// Paginator to paginate the issues
$pag = null;
if ($working)
{
$pag = new Pluf_Paginator(new IDF_Issue());
$title = __('Your Dashboard - Working Issues');
$pag->forced_where = new Pluf_SQL("owner = " . $request->user->id);
}
if (count($otags) == 0) $otags[] = 0;
if ($working) {
$title = __('Your Dashboard - Working Issues');
$f_sql = new Pluf_SQL('owner=%s AND status IN ('.implode(', ', $otags).')', array($request->user->id));
} else {
else
{
$pag = new Pluf_Paginator(new IDF_Issue());
$title = __('Your Dashboard - Submitted Issues');
$f_sql = new Pluf_SQL('submitter=%s AND status IN ('.implode(', ', $otags).')', array($request->user->id));
$pag->forced_where = new Pluf_SQL("submitter = " . $request->user->id);
}
// Get stats about the issues
$sql = new Pluf_SQL('submitter=%s AND status IN ('.implode(', ', $otags).')', array($request->user->id));
$nb_submit = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
$sql = new Pluf_SQL('owner=%s AND status IN ('.implode(', ', $otags).')', array($request->user->id));
$nb_owner = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
$pag->model_view = 'project_find';
$pag->item_extra_props = array('current_user' => $request->user);
$pag->summary = __('This table shows the open issues.');
$pag->forced_where = $f_sql;
$pag->action = ($working) ? 'idf_dashboard' : 'idf_dashboard_submit';
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
$pag->sort_reverse_order = array('modif_dtime');
$user = $users[0];
$user_data = IDF_UserData::factory($user);
$otags = array();
// Note that this approach does not scale, we will need to add
// a table to cache the meaning of the tags for large forges.
foreach (IDF_Views::getProjects($user) as $project) {
$otags = array_merge($otags, $project->getTagIdsByStatus('open'));
$ownedprojects = IDF_Views::getOwnedProjects($request->user);
$pubprojects = array();
$privprojects = 0;
foreach($ownedprojects as $proj)
{
if ($proj->private == 1)
{
$privprojects += 1;
continue;
} else {
$pubprojects[] = $proj;
}
}
$false = Pluf_DB_BooleanToDb(false, $db);
$sql_results = $db->select(
'SELECT id FROM '.$db->pfx.'idf_projects '.
'WHERE '.$db->qn('private').'='.$false
);
$projectstats = IDF_Views::getProjectsStatistics($pubprojects);
//print_r($projectstats);
//echo $privprojects;
$ids = array();
foreach ($sql_results as $id) {
$ids[] = $id['id'];
}
$f_sql = new Pluf_SQL('owner=%s AND status IN (' .implode(', ', $otags) . ') AND project IN (' . implode(', ', $ids) . ' )', array($user->id));
//$pubprojects = Pluf::factory("IDF_Project")->getList(array('filter' => ""));
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->model_view = "project_find_private";
$pag->class = 'recent-issues';
$pag->item_extra_props = array('current_user' => $request->user);
$pag->summary = __('This table shows the open issues.');
$pag->forced_where = $f_sql;
$pag->forced_where = new Pluf_SQL("owner = " . $request->user->id);
$pag->action = 'idf_dashboard';
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
$pag->sort_reverse_order = array('modif_dtime');
$list_display = array(
'id' => __('Id'),
array('project', 'Pluf_Paginator_FkToString', __('Project')),
//'id' => __('Id'),
//array('project', 'Pluf_Paginator_FkToString', __('Project')),
array('project', 'IDF_Views_ProjectLink', __('Project')),
array('summary', 'IDF_Views_IssueSummaryAndLabels', __('Summary')),
array('status', 'IDF_Views_Issue_ShowStatus', __('Status')),
array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')),
$pag->no_results_text = __('This user has no issues assigned to them!');
$pag->setFromRequest($request);
$pag2 = new Pluf_Paginator(new IDF_Commit());
$pag->model_view = "project_find_private";
$pag2->class = 'recent-issues';
$pag2->summary = __('This table shows the latest commits of this user.');
$pag2->forced_where = new Pluf_SQL("author = " . $request->user->id);
$pag2->action = 'idf_dashboard';
$pag2->sort_order = array('creation_dtime', 'ASC'); // will be reverted
$pag2->sort_reverse_order = array('creation_dtime');
$list_display = array(
//'id' => __('Id'),
array('project', 'IDF_Views_ProjectLink', __('Project')),
'summary' => __('Summary'),
array('creation_dtime', 'Pluf_Paginator_DateAgo', __('Commit sent')),
);
$pag2->configure($list_display, array(), array('creation_dtime'));
$pag2->items_per_page = 10;
$pag2->no_results_text = __('This user has not made any commits yet!');
$pag2->setFromRequest($request);
$projects = IDF_Views::getOwnedProjects($user);
return Pluf_Shortcuts_RenderToResponse('idf/user/public.html',
array('page_title' => (string) $user,
'member' => $user,
'user_data' => $user_data,
'projects' => $projects,
'issues' => $pag
'issues' => $pag,
'commits' => $pag2,
'stats' => new Pluf_Template_ContextVars($projectstats),
'privatecount' => $privprojects
),
$request);
}
}
function IDF_Views_ProjectLink($field, $issue, $extra='')
{
$project = $issue->get_project();
$edit = Pluf_HTTP_URL_urlForView('IDF_Views_Project::home',
array($project->shortname));
return sprintf('<a href="%s">%s</a>', $edit, $project->shortname);
}
/**
* Display the summary of an issue, then on a new line, display the
* list of labels with a link to a view "by label only".
indefero/src/IDF/templates/idf/user/public.html
4444
4545
4646
47
48
49
50
51
52
53
54
55
56
57
58
4759
4860
49
50
51
52
53
54
55
56
57
58
59
61
62
63
64
65
66
67
68
69
70
71
6072
6173
6274
6375
6476
65
77
6678
67
68
69
70
71
72
73
79
80
81
82
83
84
85
86
87
88
7489
7590
7691
<td>{$member.date_joined|date}</td>
</tr>
</table>
Issues user is working on:<br/><br/>
{$issues.render}
Last commits of user:<br /><br/>
{$commits.render}
{/block}
{block context}
<div class="issue-submit-info">
<p>{blocktrans}You are looking at the public profile of {$member}.{/blocktrans}</p>
</div>
Projects:
<table class="form">
{if $projects}
{foreach $projects as $p}
{if $p.private == 0}
<tr>
<td>
<a href="{url 'IDF_Views_Project::home', array($p.name)}">{$p.name} - {$p.shortdesc}</a>
</td>
</tr>
{/if}
{/foreach}
{else}
{if $projects}
{foreach $projects as $p}
{if $p.private == 0}
<tr>
<td>
<a href="{url 'IDF_Views_Project::home', array($p.name)}">{$p.name} - {$p.shortdesc}</a>
</td>
</tr>
{/if}
{/foreach}
{else}
<tr>
<td>
This user is not working on any projects
</td>
</tr>
{/if}
{/if}
</table>
Issues user is working on:<br/><br/>
{$issues.render}
{/block}
{block context}
<div class="issue-submit-info">
<p>{blocktrans}You are looking at the public profile of {$member}.{/blocktrans}</p>
</div>
<strong>Project Stats</strong>
<dl class="statistics smaller">
<dt>{trans 'Issues:'}</dt><dd>{$stats.issues}</dd>
<dt>{trans 'Commits:'}</dt><dd>{$stats.commits}</dd>
<dt>{trans 'Documentations:'}</dt><dd>{$stats.docpages}</dd>
<dt>{trans 'Downloads:'}</dt><dd>{$stats.downloads}</dd>
<dt>{trans 'Code reviews:'}</dt><dd>{$stats.reviews}</dd>
<dt>{trans 'Private Projects:'}</dt><dd>{$privatecount}</dd>
<dt>Public Projects:</dt><dd>{$stats.proj_count}</dd>
</dl>
{/block}

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.43476s using 20 queries.