Commit overview section data is fixed

* Fixed commit counter shown in overview section
* Added company break-down in engineer details
* Garbage collector for old updates is fixed

Fixes bug 1202184

Change-Id: I91752671460a2b18f8c0cab3b1aed65d0c62641d
This commit is contained in:
Ilya Shakhat 2013-07-17 18:22:52 +04:00
parent 31101fa618
commit 2aaf873b38
6 changed files with 61 additions and 64 deletions

View File

@ -0,0 +1,28 @@
<h3>Commit overview</h3>
{% if blueprints %}
<div>Blueprints:
<ol>
{% for rec in blueprints %}
<li>
<a href="https://blueprints.launchpad.net/{{ rec['module'] }}/+spec/{{ rec['id'] }}">{{ rec['id'] }}</a>
<small>{{ rec['module'] }}</small>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
{% if bugs %}
<div>Bugs:
<ol>
{% for rec in bugs %}
<li>
<a href="https://bugs.launchpad.net/bugs/{{ rec['id'] }}">{{ rec['id'] }}</a>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
<div>Total commits: <b>{{ commit_count }}</b></div>
<div>Total LOC: <b>{{ loc }}</b></div>

View File

@ -53,33 +53,6 @@
</table>
<div class="spacer"></div>
<h3>Commit overview</h3>
{% if blueprints %}
<div>Blueprints:
<ol>
{% for rec in blueprints %}
<li>
<a href="https://blueprints.launchpad.net/{{ rec['module'] }}/+spec/{{ rec['id'] }}">{{ rec['id'] }}</a>
<small>{{ rec['module'] }}</small>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
{% if bugs %}
<div>Bugs:
<ol>
{% for rec in bugs %}
<li>
<a href="https://bugs.launchpad.net/bugs/{{ rec['id'] }}">{{ rec['id'] }}</a>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
<div>Total commits: <b>{{ commits|length }}</b></div>
<div>Total LOC: <b>{{ loc }}</b></div>
{% include "commits_overview.html" %}
{% endblock %}

View File

@ -32,6 +32,11 @@
{% for rec in commits %}
<div>
<h4>{{ rec.date|datetimeformat }} to <a href="https://launchpad.net/{{ rec.module }}">{{ rec.module }}</a>
{% if user.companies[-1].company_name != rec.company_name %}
(
{{ rec.company_name|link('/companies/' + rec.company_name)|safe }}
)
{% endif %}
</h4>
{% if rec.correction_comment %}
<div style='font-weight: bold; color: red; padding-left: 2em;'>Commit corrected: {{ rec.correction_comment }}</div>
@ -65,34 +70,18 @@
</table>
<div class="spacer"></div>
<h3>Commit overview</h3>
{% if blueprints %}
<div>Blueprints:
<ol>
{% for rec in blueprints %}
<li>
<a href="https://blueprints.launchpad.net/{{ rec['module'] }}/+spec/{{ rec['id'] }}">{{ rec['id'] }}</a>
<small>{{ rec['module'] }}</small>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
{% include "commits_overview.html" %}
{% if bugs %}
<div>Bugs:
<ol>
{% for rec in bugs %}
<li>
<a href="https://bugs.launchpad.net/bugs/{{ rec['id'] }}">{{ rec['id'] }}</a>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
<h4>Contribution per companies:</h4>
{% for company_info in user.companies %}
<div>
{% set company_name = company_info.company_name %}
{{ company_name|link('/companies/' + company_name)|safe }}:
<b>{{ companies[company_name].commits }}</b> commits and
<b>{{ companies[company_name].loc }}</b> LOC
</div>
{% endfor %}
<div>Total commits: <b>{{ commits|length }}</b></div>
<div>Total LOC: <b>{{ loc }}</b></div>
{% endif %}
{% endblock %}

View File

@ -223,7 +223,7 @@ def exception_handler():
try:
return f(*args, **kwargs)
except Exception as e:
LOG.debug(e)
LOG.error(e)
flask.abort(404)
return exception_handler_decorated_function
@ -291,6 +291,7 @@ def page_not_found(e):
def contribution_details(records, limit=DEFAULT_RECORDS_LIMIT):
blueprints_map = {}
bugs_map = {}
companies_map = {}
commits = []
loc = 0
@ -311,6 +312,14 @@ def contribution_details(records, limit=DEFAULT_RECORDS_LIMIT):
else:
bugs_map[bug] = [record]
company = record['company_name']
if company:
if company in companies_map:
companies_map[company]['loc'] += record['loc']
companies_map[company]['commits'] += 1
else:
companies_map[company] = {'loc': record['loc'], 'commits': 1}
blueprints = sorted([{'id': key,
'module': value[0]['module'],
'records': value}
@ -325,6 +334,8 @@ def contribution_details(records, limit=DEFAULT_RECORDS_LIMIT):
'blueprints': blueprints,
'bugs': bugs,
'commits': commits[0:limit],
'commit_count': len(commits),
'companies': companies_map,
'loc': loc,
}
return result

View File

@ -35,7 +35,7 @@ def get_pids():
for pid in psutil.get_pid_list():
try:
p = psutil.Process(pid)
if p.cmdline and p.cmdline[0].find('/uwsgi '):
if p.cmdline and p.cmdline[0].find('/uwsgi'):
uwsgi_dict[p.pid] = p.parent
except _error.NoSuchProcess:
# the process may disappear after get_pid_list call, ignore it

View File

@ -143,14 +143,10 @@ class MemcachedStorage(RuntimeStorage):
if n < min_update:
min_update = n
first_valid_update_id = self.memcached.get('first_valid_update_id')
if not first_valid_update_id:
first_valid_update_id = 0
for i in range(first_valid_update_id, min_update):
self.memcached.delete(UPDATE_ID_PREFIX + str(i))
self.memcached.set('first_valid_update_id', min_update)
first_valid_update = self.memcached.get('first_valid_update') or 0
self.memcached.delete_multi(range(first_valid_update, min_update),
key_prefix=UPDATE_ID_PREFIX)
self.memcached.set('first_valid_update', min_update)
def _get_update_count(self):
return self.memcached.get('update:count') or 0