Fixed sorting in members_table and fixed dropdown

closes bug 1308976
Changed "two years" to "all" in date dropdown

Change-Id: I778bcbb845d67ed5fcc39e7e360701c83b7d13a0
This commit is contained in:
pkholkin 2014-04-23 14:07:39 +04:00
parent f388815c60
commit 97a64afd68
3 changed files with 13 additions and 5 deletions

View File

@ -28,6 +28,7 @@ from stackalytics.processor import utils
DEFAULT_DAYS_COUNT = 7
FIRST_MEMBER_DATE = "2012-Jul-18"
blueprint = flask.Blueprint('reports', __name__, url_prefix='/report')
@ -133,8 +134,12 @@ def contribution(module, days):
@decorators.templated()
def registrants():
days = int(flask.request.args.get('days') or DEFAULT_DAYS_COUNT)
all_days = int(time.time() - utils.date_to_timestamp_ext(
FIRST_MEMBER_DATE)) / (24 * 60 * 60) + 1
return {
'days': days
'days': days,
'all_days': all_days
}

View File

@ -26,14 +26,13 @@
var tableData = data["members"];
var tableColumns = [];
var sort_by_column = 0;
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 user_link = tableData[i].member_uri;
tableData[i].index = i + 1;
tableData[i].link = "<a href=\"" + user_link + "\">" + tableData[i].author_name + "</a>";
tableData[i].date = tableData[i].date_str;
@ -43,7 +42,7 @@
if (table_id) {
$("#" + table_id).dataTable({
"aaSorting": [
[ sort_by_column, "asc" ]
[ sort_by_column, "desc" ]
],
"bFilter": true,
"bInfo": true,
@ -277,7 +276,7 @@
<option value="93">quarter</option>
<option value="183">half year</option>
<option value="365">year</option>
<option value="730">two years</option>
<option value="{{ all_days }}">all</option>
</select>
</div>

View File

@ -328,6 +328,10 @@ def get_members(records):
['author_name', 'date', 'company_name', 'member_uri']])
nr['date_str'] = helpers.format_date(nr['date'])
response.append(nr)
response.sort(key=lambda x: x['date'], reverse=True)
utils.add_index(response)
return response