Updating public profile by writing new code that reduces queries and adds some more features - also fixes issue 13
This commit is contained in:
parent
ccece87dee
commit
18e191abc0
@ -102,6 +102,14 @@ class IDF_Commit extends Pluf_Model
|
|||||||
'help_text' => 'Date of creation by the scm',
|
'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()
|
function __toString()
|
||||||
|
@ -35,6 +35,7 @@ class IDF_Issue extends Pluf_Model
|
|||||||
|
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
|
//$tagtbl = "indefero_idf_tags";
|
||||||
$this->_a['table'] = 'idf_issues';
|
$this->_a['table'] = 'idf_issues';
|
||||||
$this->_a['model'] = __CLASS__;
|
$this->_a['model'] = __CLASS__;
|
||||||
$this->_a['cols'] = array(
|
$this->_a['cols'] = array(
|
||||||
@ -119,7 +120,18 @@ class IDF_Issue extends Pluf_Model
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
$table = $this->_con->pfx.'idf_issue_idf_tag_assoc';
|
$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(
|
$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' =>
|
'join_tags' =>
|
||||||
array(
|
array(
|
||||||
'join' => 'LEFT JOIN '.$table
|
'join' => 'LEFT JOIN '.$table
|
||||||
|
@ -562,7 +562,7 @@ class IDF_Views
|
|||||||
$forgestats[$key] = $count;
|
$forgestats[$key] = $count;
|
||||||
$forgestats['total'] += $count;
|
$forgestats['total'] += $count;
|
||||||
}
|
}
|
||||||
$forgestats['proj_count'] = count($projects);
|
$forgestats['proj_count'] = count($projects);
|
||||||
return $forgestats;
|
return $forgestats;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,32 +79,37 @@ class IDF_Views_User
|
|||||||
public function dashboard($request, $match, $working=true)
|
public function dashboard($request, $match, $working=true)
|
||||||
{
|
{
|
||||||
|
|
||||||
$otags = array();
|
/*
|
||||||
// Note that this approach does not scale, we will need to add
|
* This is a little bit better - but still not perfect
|
||||||
// a table to cache the meaning of the tags for large forges.
|
* It has a N*3 SQL query for each issue that is assigned to the user
|
||||||
foreach (IDF_Views::getProjects($request->user) as $project) {
|
* As long as the user isn't assigned 100+ issues - it should hold
|
||||||
$otags = array_merge($otags, $project->getTagIdsByStatus('open'));
|
*/
|
||||||
}
|
$ownedissues = Pluf::factory("IDF_Issue")->getList(array('filter' => "owner = " . $request->user->id, 'view' => 'project_find'));
|
||||||
if (count($otags) == 0) $otags[] = 0;
|
$submittedissues = Pluf::factory("IDF_Issue")->getList(array('filter' => "submitter = " . $request->user->id, 'view' => 'project_find'));
|
||||||
if ($working) {
|
$nb_owner = count($ownedissues);
|
||||||
$title = __('Your Dashboard - Working Issues');
|
$nb_submit = count($submittedissues);
|
||||||
$f_sql = new Pluf_SQL('owner=%s AND status IN ('.implode(', ', $otags).')', array($request->user->id));
|
|
||||||
} else {
|
|
||||||
$title = __('Your Dashboard - Submitted Issues');
|
|
||||||
$f_sql = new Pluf_SQL('submitter=%s AND status IN ('.implode(', ', $otags).')', array($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
|
// Paginator to paginate the issues
|
||||||
$pag = new Pluf_Paginator(new IDF_Issue());
|
$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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pag = new Pluf_Paginator(new IDF_Issue());
|
||||||
|
$title = __('Your Dashboard - Submitted Issues');
|
||||||
|
$pag->forced_where = new Pluf_SQL("submitter = " . $request->user->id);
|
||||||
|
|
||||||
|
}
|
||||||
$pag->class = 'recent-issues';
|
$pag->class = 'recent-issues';
|
||||||
|
$pag->model_view = 'project_find';
|
||||||
$pag->item_extra_props = array('current_user' => $request->user);
|
$pag->item_extra_props = array('current_user' => $request->user);
|
||||||
$pag->summary = __('This table shows the open issues.');
|
$pag->summary = __('This table shows the open issues.');
|
||||||
$pag->forced_where = $f_sql;
|
|
||||||
$pag->action = ($working) ? 'idf_dashboard' : 'idf_dashboard_submit';
|
$pag->action = ($working) ? 'idf_dashboard' : 'idf_dashboard_submit';
|
||||||
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
|
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
|
||||||
$pag->sort_reverse_order = array('modif_dtime');
|
$pag->sort_reverse_order = array('modif_dtime');
|
||||||
@ -281,36 +286,41 @@ class IDF_Views_User
|
|||||||
$user = $users[0];
|
$user = $users[0];
|
||||||
$user_data = IDF_UserData::factory($user);
|
$user_data = IDF_UserData::factory($user);
|
||||||
|
|
||||||
$otags = array();
|
$ownedprojects = IDF_Views::getOwnedProjects($request->user);
|
||||||
// Note that this approach does not scale, we will need to add
|
|
||||||
// a table to cache the meaning of the tags for large forges.
|
$pubprojects = array();
|
||||||
foreach (IDF_Views::getProjects($user) as $project) {
|
$privprojects = 0;
|
||||||
$otags = array_merge($otags, $project->getTagIdsByStatus('open'));
|
|
||||||
|
foreach($ownedprojects as $proj)
|
||||||
|
{
|
||||||
|
if ($proj->private == 1)
|
||||||
|
{
|
||||||
|
$privprojects += 1;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
$pubprojects[] = $proj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$false = Pluf_DB_BooleanToDb(false, $db);
|
$projectstats = IDF_Views::getProjectsStatistics($pubprojects);
|
||||||
$sql_results = $db->select(
|
//print_r($projectstats);
|
||||||
'SELECT id FROM '.$db->pfx.'idf_projects '.
|
//echo $privprojects;
|
||||||
'WHERE '.$db->qn('private').'='.$false
|
|
||||||
);
|
|
||||||
|
|
||||||
$ids = array();
|
//$pubprojects = Pluf::factory("IDF_Project")->getList(array('filter' => ""));
|
||||||
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));
|
|
||||||
|
|
||||||
$pag = new Pluf_Paginator(new IDF_Issue());
|
$pag = new Pluf_Paginator(new IDF_Issue());
|
||||||
|
$pag->model_view = "project_find_private";
|
||||||
$pag->class = 'recent-issues';
|
$pag->class = 'recent-issues';
|
||||||
$pag->item_extra_props = array('current_user' => $request->user);
|
$pag->item_extra_props = array('current_user' => $request->user);
|
||||||
$pag->summary = __('This table shows the open issues.');
|
$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->action = 'idf_dashboard';
|
||||||
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
|
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
|
||||||
$pag->sort_reverse_order = array('modif_dtime');
|
$pag->sort_reverse_order = array('modif_dtime');
|
||||||
$list_display = array(
|
$list_display = array(
|
||||||
'id' => __('Id'),
|
//'id' => __('Id'),
|
||||||
array('project', 'Pluf_Paginator_FkToString', __('Project')),
|
//array('project', 'Pluf_Paginator_FkToString', __('Project')),
|
||||||
|
array('project', 'IDF_Views_ProjectLink', __('Project')),
|
||||||
array('summary', 'IDF_Views_IssueSummaryAndLabels', __('Summary')),
|
array('summary', 'IDF_Views_IssueSummaryAndLabels', __('Summary')),
|
||||||
array('status', 'IDF_Views_Issue_ShowStatus', __('Status')),
|
array('status', 'IDF_Views_Issue_ShowStatus', __('Status')),
|
||||||
array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')),
|
array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')),
|
||||||
@ -320,19 +330,50 @@ class IDF_Views_User
|
|||||||
$pag->no_results_text = __('This user has no issues assigned to them!');
|
$pag->no_results_text = __('This user has no issues assigned to them!');
|
||||||
$pag->setFromRequest($request);
|
$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);
|
$projects = IDF_Views::getOwnedProjects($user);
|
||||||
return Pluf_Shortcuts_RenderToResponse('idf/user/public.html',
|
return Pluf_Shortcuts_RenderToResponse('idf/user/public.html',
|
||||||
array('page_title' => (string) $user,
|
array('page_title' => (string) $user,
|
||||||
'member' => $user,
|
'member' => $user,
|
||||||
'user_data' => $user_data,
|
'user_data' => $user_data,
|
||||||
'projects' => $projects,
|
'projects' => $projects,
|
||||||
'issues' => $pag
|
'issues' => $pag,
|
||||||
|
'commits' => $pag2,
|
||||||
|
'stats' => new Pluf_Template_ContextVars($projectstats),
|
||||||
|
'privatecount' => $privprojects
|
||||||
),
|
),
|
||||||
$request);
|
$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
|
* 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".
|
* list of labels with a link to a view "by label only".
|
||||||
|
@ -44,33 +44,48 @@
|
|||||||
<td>{$member.date_joined|date}</td>
|
<td>{$member.date_joined|date}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</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:
|
Projects:
|
||||||
<table class="form">
|
<table class="form">
|
||||||
{if $projects}
|
{if $projects}
|
||||||
{foreach $projects as $p}
|
{foreach $projects as $p}
|
||||||
{if $p.private == 0}
|
{if $p.private == 0}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{url 'IDF_Views_Project::home', array($p.name)}">{$p.name} - {$p.shortdesc}</a>
|
<a href="{url 'IDF_Views_Project::home', array($p.name)}">{$p.name} - {$p.shortdesc}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{else}
|
{else}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
This user is not working on any projects
|
This user is not working on any projects
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
</table>
|
</table>
|
||||||
Issues user is working on:<br/><br/>
|
<strong>Project Stats</strong>
|
||||||
{$issues.render}
|
<dl class="statistics smaller">
|
||||||
{/block}
|
<dt>{trans 'Issues:'}</dt><dd>{$stats.issues}</dd>
|
||||||
{block context}
|
<dt>{trans 'Commits:'}</dt><dd>{$stats.commits}</dd>
|
||||||
<div class="issue-submit-info">
|
<dt>{trans 'Documentations:'}</dt><dd>{$stats.docpages}</dd>
|
||||||
<p>{blocktrans}You are looking at the public profile of {$member}.{/blocktrans}</p>
|
<dt>{trans 'Downloads:'}</dt><dd>{$stats.downloads}</dd>
|
||||||
</div>
|
<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}
|
{/block}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user