From a18739e4158b6ba69046e9d0cf68c47c2b90faa6 Mon Sep 17 00:00:00 2001 From: pkholkin Date: Tue, 1 Apr 2014 13:50:15 +0400 Subject: [PATCH] Frontend for openstack.org members report implements bp member-directory Change-Id: I850f0081a465c4de4d9f2b3a098c6b0889da1f4b --- dashboard/decorators.py | 1 + dashboard/helpers.py | 2 +- dashboard/parameters.py | 1 + dashboard/reports.py | 12 + dashboard/static/css/style.css | 2 +- dashboard/templates/reports/registrants.html | 348 +++++++++++++++++++ dashboard/web.py | 16 +- 7 files changed, 379 insertions(+), 3 deletions(-) create mode 100644 dashboard/templates/reports/registrants.html diff --git a/dashboard/decorators.py b/dashboard/decorators.py index 81dd27638..06b117463 100644 --- a/dashboard/decorators.py +++ b/dashboard/decorators.py @@ -211,6 +211,7 @@ def aggregate_filter(): 'emails': (incremental_filter, None), 'bpd': (incremental_filter, None), 'bpc': (incremental_filter, None), + 'members': (incremental_filter, None), } if metric not in metric_to_filters_map: metric = parameters.get_default('metric') diff --git a/dashboard/helpers.py b/dashboard/helpers.py index f72ee9c6d..7a7e6b78a 100644 --- a/dashboard/helpers.py +++ b/dashboard/helpers.py @@ -174,7 +174,7 @@ def format_datetime(timestamp): def format_date(timestamp): - return datetime.datetime.utcfromtimestamp(timestamp).strftime('%d-%b-%y') + return datetime.datetime.utcfromtimestamp(timestamp).strftime('%d %b %Y') def format_launchpad_module_link(module): diff --git a/dashboard/parameters.py b/dashboard/parameters.py index bb4e4a886..4451f0f60 100644 --- a/dashboard/parameters.py +++ b/dashboard/parameters.py @@ -44,6 +44,7 @@ METRIC_TO_RECORD_TYPE = { 'emails': 'email', 'bpd': 'bpd', 'bpc': 'bpc', + 'members': 'member', } DEFAULT_RECORDS_LIMIT = 10 diff --git a/dashboard/reports.py b/dashboard/reports.py index 44dad7bb3..4807a2acd 100644 --- a/dashboard/reports.py +++ b/dashboard/reports.py @@ -27,6 +27,8 @@ from dashboard import vault from stackalytics.processor import utils +DEFAULT_DAYS_COUNT = 7 + blueprint = flask.Blueprint('reports', __name__, url_prefix='/report') @@ -126,6 +128,16 @@ def contribution(module, days): } +@blueprint.route('/registrants') +@decorators.exception_handler() +@decorators.templated() +def registrants(): + days = int(flask.request.args.get('days') or DEFAULT_DAYS_COUNT) + return { + 'days': days + } + + def _get_punch_card_data(records): punch_card_raw = [] # matrix days x hours for wday in xrange(0, 7): diff --git a/dashboard/static/css/style.css b/dashboard/static/css/style.css index 5c9a2151b..5817ff365 100644 --- a/dashboard/static/css/style.css +++ b/dashboard/static/css/style.css @@ -27,7 +27,7 @@ div.page { margin: 0 auto; } -div.page h2 { +h2 { font-family: 'PT Sans Narrow', 'Arial Narrow', arial, sans-serif; font-size: 23px; font-weight: normal; diff --git a/dashboard/templates/reports/registrants.html b/dashboard/templates/reports/registrants.html new file mode 100644 index 000000000..27abc6fdc --- /dev/null +++ b/dashboard/templates/reports/registrants.html @@ -0,0 +1,348 @@ +{% extends "reports/base_report.html" %} + +{% block title %} + OpenStack foundation members +{% endblock %} + +{% block scripts %} + + + + + +{% endblock %} + + +{% block content %} + + + + + +
+
+ + +
+ +
+ + +
+
+ + + + + + + +
+

OpenStack foundation member companies

+ +
+ + + + + + + + + + +
#CompanyMembers Count
+
+
+

Members by company

+
+
+ +
+
+
+
+ + + + + +
+

Individual Members

+ +
+ + + + + + + + + + + +
#EngineerDate JoinedCompany
+
+
+ +{% endblock %} diff --git a/dashboard/web.py b/dashboard/web.py index a1df9d2f0..de5b4fb64 100644 --- a/dashboard/web.py +++ b/dashboard/web.py @@ -118,7 +118,7 @@ def get_modules(records, metric_filter, finalize_handler): def get_core_engineer_branch(user, modules): is_core = None - for (module, branch) in user['core']: + for (module, branch) in (user.get('core') or []): if module in modules: is_core = branch if branch == 'master': # master is preferable, but stables are ok @@ -315,6 +315,20 @@ def get_module(module): flask.abort(404) +@app.route('/api/1.0/members') +@decorators.jsonify('members') +@decorators.exception_handler() +@decorators.record_filter(ignore=['release', 'project_type', 'module']) +def get_members(records): + response = [] + for record in records: + nr = dict([(k, record[k]) for k in + ['author_name', 'date', 'company_name', 'member_uri']]) + nr['date_str'] = helpers.format_date(nr['date']) + response.append(nr) + return response + + @app.route('/api/1.0/stats/bp') @decorators.jsonify('stats') @decorators.exception_handler()