diff --git a/dashboard/templates/reports/members.html b/dashboard/templates/reports/members.html index bcad0a911..bd082a52a 100644 --- a/dashboard/templates/reports/members.html +++ b/dashboard/templates/reports/members.html @@ -60,6 +60,49 @@ }); } + function show_new_companies_table(options) { + var table_column_names = ["index", "link", "date"]; + var table_id = "new_companies_table"; + + $.ajax({ + url: make_uri("/api/1.0/new_companies", options), + dataType: "json", + success: function (data) { + var tableData = data["stats"]; + + var tableColumns = []; + var sort_by_column = 2; + for (var i = 0; i < table_column_names.length; i++) { + tableColumns.push({"mData": table_column_names[i]}); + } + + for (i = 0; i < tableData.length; i++) { + var company_link = make_uri('/report/members', {company:tableData[i].name}); + tableData[i].link = "" + tableData[i].name + ""; + tableData[i].date = tableData[i].date_str; + } + + if (table_id) { + $("#" + table_id).dataTable({ + "aaSorting": [ + [ sort_by_column, "desc" ] + ], + "bFilter": true, + "bInfo": true, + "bAutoWidth": false, + "aaData": tableData, + "aoColumns": tableColumns, + "bDestroy": true, + 'bPaginate': true, + "sPaginationType": "full_numbers", + "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]], + "iDisplayLength": 10 + }); + } + } + }); + } + function show_companies_table(options) { var table_column_names = ["index", "link", "count"]; var table_id = "companies_table"; @@ -76,14 +119,8 @@ tableColumns.push({"mData": table_column_names[i]}); } - var wasIndependent = 0; - for (i = 0; i < tableData.length; i++) { - if (tableData[i].name == '*independent') - wasIndependent = 1; - else - tableData[i].index = i + 1 - wasIndependent; - var company_link = make_uri('/report/registrants', {company:tableData[i].name}); + var company_link = make_uri('/report/members', {company:tableData[i].name}); tableData[i].link = "" + tableData[i].name + ""; tableData[i].count = tableData[i].metric; } @@ -184,9 +221,12 @@ {% if company == '' %} show_companies_table(base_options); + show_new_companies_table(base_options); renderChart("/api/1.0/stats/companies", "members_container", "members_chart", base_options); {% else %} $('#companies_block').hide(); + $('#new_companies_table_header').hide(); + $('#new_companies_table').hide(); {% endif %} } @@ -320,9 +360,9 @@ - +
-
+

Individual Members

@@ -340,6 +380,26 @@
+ +
+

New Companies

+
+ +
+ + + + + + + + + + + +
#CompanyFirst Member Joined
+
+ diff --git a/dashboard/web.py b/dashboard/web.py index 42e85cf52..8b13765c7 100644 --- a/dashboard/web.py +++ b/dashboard/web.py @@ -94,6 +94,35 @@ def _get_aggregated_stats(records, metric_filter, keys, param_id, return response +@app.route('/api/1.0/new_companies') +@decorators.jsonify('stats') +@decorators.exception_handler() +@decorators.record_filter(ignore='start_date') +def get_new_companies(records): + + days = int(flask.request.args.get('days') or reports.DEFAULT_DAYS_COUNT) + start_date = int(time.time()) - days * 24 * 60 * 60 + + result = {} + for record in records: + company_name = record['company_name'] + date = record['date'] + + if company_name not in result or result[company_name] > date: + result[company_name] = date + + response = list(({'name': company_name, + 'date': result[company_name], + 'date_str': helpers.format_date(result[company_name])}) + for company_name in result + if result[company_name] >= start_date) + + response.sort(key=lambda x: x['date'], reverse=True) + utils.add_index(response) + + return response + + @app.route('/api/1.0/stats/companies') @decorators.jsonify('stats') @decorators.exception_handler() @@ -320,6 +349,7 @@ def get_module(module): def get_members(records): response = [] for record in records: + record = vault.extend_record(record) nr = dict([(k, record[k]) for k in ['author_name', 'date', 'company_name', 'member_uri']]) nr['date_str'] = helpers.format_date(nr['date']) diff --git a/etc/default_data.json b/etc/default_data.json index 1f9fb5aa1..32b4f23d8 100644 --- a/etc/default_data.json +++ b/etc/default_data.json @@ -5747,7 +5747,7 @@ { "domains": ["cisco.com"], "company_name": "Cisco Systems", - "aliases": ["Cisco System", "Cisco Systems", "Cisco Systems Inc.", "Cisco Systems, Inc.", "Cisco Systems Inc., Intel, Microsoft, Dorkbotz", "Cisco System, Inc., Nebula, Inc."] + "aliases": ["Cisco System", "Cisco Systems", "Cisco Systems Inc.", "Cisco Systems, Inc.", "Cisco Systems Inc., Intel, Microsoft, Dorkbotz", "Cisco System, Inc., Nebula, Inc.", "Cisco", "Cisco Inc"] }, { "domains": ["citrix.com"], @@ -5987,7 +5987,7 @@ { "domains": ["intel.com"], "company_name": "Intel", - "aliases": ["Intel Corp.", "Intel Corporation", "Intel Media", "Intel OTC"] + "aliases": ["Intel Corp.", "Intel Corporation", "Intel Media", "Intel OTC", "Intern at intel"] }, { "domains": ["interhost.no"], @@ -6348,7 +6348,8 @@ }, { "domains": ["suse.cz", "suse.de", "suse.com"], - "company_name": "SUSE" + "company_name": "SUSE", + "aliases": ["SUSE Linux Products GmbH"] }, { "domains": ["swiftstack.com"],