diff --git a/dashboard/templates/commits_overview.html b/dashboard/templates/commits_overview.html new file mode 100644 index 000000000..44791d9f8 --- /dev/null +++ b/dashboard/templates/commits_overview.html @@ -0,0 +1,28 @@ +

Commit overview

+{% if blueprints %} +
Blueprints: +
    + {% for rec in blueprints %} +
  1. + {{ rec['id'] }} + {{ rec['module'] }} +
  2. + {% endfor %} +
+
+{% endif %} + +{% if bugs %} +
Bugs: +
    + {% for rec in bugs %} +
  1. + {{ rec['id'] }} +
  2. + {% endfor %} +
+
+{% endif %} + +
Total commits: {{ commit_count }}
+
Total LOC: {{ loc }}
diff --git a/dashboard/templates/company_details.html b/dashboard/templates/company_details.html index 2257f67e5..a6e6e77e3 100644 --- a/dashboard/templates/company_details.html +++ b/dashboard/templates/company_details.html @@ -53,33 +53,6 @@
-

Commit overview

- {% if blueprints %} -
Blueprints: -
    - {% for rec in blueprints %} -
  1. - {{ rec['id'] }} - {{ rec['module'] }} -
  2. - {% endfor %} -
-
- {% endif %} - - {% if bugs %} -
Bugs: -
    - {% for rec in bugs %} -
  1. - {{ rec['id'] }} -
  2. - {% endfor %} -
-
- {% endif %} - -
Total commits: {{ commits|length }}
-
Total LOC: {{ loc }}
+ {% include "commits_overview.html" %} {% endblock %} diff --git a/dashboard/templates/engineer_details.html b/dashboard/templates/engineer_details.html index 3fb0ff1b4..dac1e7c22 100644 --- a/dashboard/templates/engineer_details.html +++ b/dashboard/templates/engineer_details.html @@ -32,6 +32,11 @@ {% for rec in commits %}

{{ rec.date|datetimeformat }} to {{ rec.module }} + {% if user.companies[-1].company_name != rec.company_name %} + ( + {{ rec.company_name|link('/companies/' + rec.company_name)|safe }} + ) + {% endif %}

{% if rec.correction_comment %}
Commit corrected: {{ rec.correction_comment }}
@@ -65,34 +70,18 @@
-

Commit overview

- {% if blueprints %} -
Blueprints: -
    - {% for rec in blueprints %} -
  1. - {{ rec['id'] }} - {{ rec['module'] }} -
  2. - {% endfor %} -
-
- {% endif %} + {% include "commits_overview.html" %} - {% if bugs %} -
Bugs: -
    - {% for rec in bugs %} -
  1. - {{ rec['id'] }} -
  2. - {% endfor %} -
-
- {% endif %} +

Contribution per companies:

+ {% for company_info in user.companies %} +
+ {% set company_name = company_info.company_name %} + {{ company_name|link('/companies/' + company_name)|safe }}: + {{ companies[company_name].commits }} commits and + {{ companies[company_name].loc }} LOC +
+ {% endfor %} -
Total commits: {{ commits|length }}
-
Total LOC: {{ loc }}
{% endif %} {% endblock %} diff --git a/dashboard/web.py b/dashboard/web.py index d2285fcbc..a1cfe088e 100644 --- a/dashboard/web.py +++ b/dashboard/web.py @@ -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 diff --git a/stackalytics/processor/main.py b/stackalytics/processor/main.py index 35ba96b42..8a3f02211 100644 --- a/stackalytics/processor/main.py +++ b/stackalytics/processor/main.py @@ -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 diff --git a/stackalytics/processor/runtime_storage.py b/stackalytics/processor/runtime_storage.py index f5d2ca9ba..164df2db0 100644 --- a/stackalytics/processor/runtime_storage.py +++ b/stackalytics/processor/runtime_storage.py @@ -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