diff --git a/dashboard/decorators.py b/dashboard/decorators.py index 818c71559..d11d9030d 100644 --- a/dashboard/decorators.py +++ b/dashboard/decorators.py @@ -183,15 +183,20 @@ def aggregate_filter(): mark_distribution.append('0') new_record[key] = 0 - positive_ratio = ' (%.1f%%)' % ( - (positive * 100.0) / record['metric']) - new_record['mark_ratio'] = ( - '|'.join(mark_distribution) + positive_ratio) - new_record['positive_ratio'] = positive_ratio new_record['disagreements'] = record.get('disagreements', 0) - new_record['disagreement_ratio'] = '%.1f%%' % ( - (record.get('disagreements', 0) * 100.0) / record['metric'] - ) + if record['metric']: + positive_ratio = '%.1f%%' % ( + (positive * 100.0) / record['metric']) + new_record['disagreement_ratio'] = '%.1f%%' % ( + (record.get('disagreements', 0) * 100.0) / + record['metric']) + else: + positive_ratio = helpers.INFINITY_HTML + new_record['disagreement_ratio'] = helpers.INFINITY_HTML + new_record['mark_ratio'] = ('|'.join(mark_distribution) + + ' (' + positive_ratio + ')') + new_record['positive_ratio'] = positive_ratio + return new_record metric_param = (flask.request.args.get('metric') or diff --git a/dashboard/helpers.py b/dashboard/helpers.py index d769fa8a2..641c35433 100644 --- a/dashboard/helpers.py +++ b/dashboard/helpers.py @@ -24,6 +24,8 @@ from dashboard import vault from stackalytics.processor import utils +INFINITY_HTML = '∞' + gravatar = gravatar_ext.Gravatar(None, size=64, rating='g', default='wavatar') diff --git a/dashboard/static/js/stackalytics-ui.js b/dashboard/static/js/stackalytics-ui.js index ea08d2156..72ad07598 100644 --- a/dashboard/static/js/stackalytics-ui.js +++ b/dashboard/static/js/stackalytics-ui.js @@ -266,7 +266,7 @@ function make_uri(uri, options) { $.extend(ops, options); } var str = $.map(ops,function (val, index) { - return index + "=" + val; + return index + "=" + encodeURIComponent(val).toLowerCase(); }).join("&"); return (str == "") ? uri : uri + "?" + str; diff --git a/dashboard/templates/reports/reviews.html b/dashboard/templates/reports/reviews.html index 3a4dab22f..5740b999a 100644 --- a/dashboard/templates/reports/reviews.html +++ b/dashboard/templates/reports/reviews.html @@ -1,13 +1,14 @@ {% extends "reports/base_report.html" %} {% block title %} -Reviews for the last {{ days }} days in {{ module }} +Contribution into {{ module }} for the last {{ days }} days {% endblock %} {% block scripts %} {% endblock %} {% block content %} -
+1 | +2 | A | -(+/- %) | ++/- | Disagreements | Ratio | +On review / patch sets | +Commits | +Emails | diff --git a/dashboard/web.py b/dashboard/web.py index e559db296..32d569156 100644 --- a/dashboard/web.py +++ b/dashboard/web.py @@ -78,8 +78,7 @@ def page_not_found(e): # AJAX Handlers --------- def _get_aggregated_stats(records, metric_filter, keys, param_id, - param_title=None, finalize_handler=None, - postprocessing=None): + param_title=None, finalize_handler=None): param_title = param_title or param_id result = dict((c, {'metric': 0, 'id': c}) for c in keys) for record in records: @@ -87,12 +86,11 @@ def _get_aggregated_stats(records, metric_filter, keys, param_id, result[record[param_id]]['name'] = record[param_title] if not finalize_handler: - finalize_handler = lambda x: x - - response = [finalize_handler(result[r]) for r in result - if result[r]['metric']] + response = [r for r in result.values() if r['metric']] + else: + response = result.values() response.sort(key=lambda x: x['metric'], reverse=True) - response = [item for item in map(postprocessing, response) if item] + response = [item for item in map(finalize_handler, response) if item] utils.add_index(response, item_filter=lambda x: x['id'] != '*independent') return response @@ -122,7 +120,7 @@ def get_modules(records, metric_filter, finalize_handler): @app.route('/api/1.0/stats/engineers') @decorators.jsonify('stats') @decorators.exception_handler() -@decorators.record_filter() +@decorators.record_filter(ignore='metric') @decorators.aggregate_filter() def get_engineers(records, metric_filter, finalize_handler): @@ -130,8 +128,20 @@ def get_engineers(records, metric_filter, finalize_handler): modules_names = parameters.get_parameter({}, 'module', 'modules') modules = vault.resolve_modules(modules_names) - def filter_core_users(record): + def postprocessing(record): + if finalize_handler: + record = finalize_handler(record) user = vault.get_user_from_runtime_storage(record['id']) + record['company'] = user['companies'][-1]['company_name'] + record['review'] = record.get('review', 0) + record['commit'] = record.get('commit', 0) + record['email'] = record.get('email', 0) + record['patch_count'] = record.get('patch_count', 0) + + if not (record['metric'] or record['review'] or record['commit'] or + record['email'] or record['patch_count']): + return + is_core = False for (module, branch) in user['core']: if module in modules: @@ -147,11 +157,25 @@ def get_engineers(records, metric_filter, finalize_handler): record['core'] = is_core return record - return _get_aggregated_stats(records, metric_filter, + def record_processing(result, record, param_id): + record_type = record['record_type'] + + result_row = result[record[param_id]] + if record_type == 'mark': + metric_filter(result, record, param_id) + elif record_type == 'commit': + result_row['commit'] = result_row.get('commit', 0) + 1 + elif record_type == 'email': + result_row['email'] = result_row.get('email', 0) + 1 + elif record_type == 'review': + result_row['review'] = result_row.get('review', 0) + 1 + result_row['patch_count'] = (result_row.get('patch_count', 0) + + record['patch_count']) + + return _get_aggregated_stats(records, record_processing, vault.get_memory_storage().get_user_ids(), 'user_id', 'author_name', - finalize_handler=finalize_handler, - postprocessing=filter_core_users) + finalize_handler=postprocessing) @app.route('/api/1.0/stats/distinct_engineers')
---|