Added "new_companies" list for the period

implements bp member-directory

Change-Id: I7e00388a7f9b1bcb4343be34738dc8ab74932f62
This commit is contained in:
pkholkin 2014-04-30 14:52:43 +04:00
parent 15800b759e
commit 850716be32
3 changed files with 103 additions and 12 deletions

View File

@ -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 = "<a href=\"" + company_link + "\">" + tableData[i].name + "</a>";
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 = "<a href=\"" + company_link + "\">" + tableData[i].name + "</a>";
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 @@
</tr>
</table>
<table style="width: 50%" cellspacing="0">
<table style="width: 100%" cellspacing="0">
<tr>
<td style="width: 100%; vertical-align: top; padding-right: 3em;">
<td style="width: 50%; vertical-align: top; padding-right: 3em;">
<h2>Individual Members</h2>
<div class="body" style="margin-right: 1em;">
@ -340,6 +380,26 @@
</table>
</div>
</td>
<td style="width: 50%; vertical-align: top; padding-right: 3em;">
<div id="new_companies_table_header">
<h2>New Companies</h2>
</div>
<div class="body" style="margin-right: 1em;">
<table id="new_companies_table">
<thead>
<tr>
<th>#</th>
<th>Company</th>
<th>First Member Joined</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</td>
</tr>
</table>

View File

@ -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'])

View File

@ -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"],