Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1457: sort was using the string value #1484

Merged
merged 2 commits into from
Dec 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/app/components/dynamic-table/dynamic-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<thead>
<tr>
<th ng-repeat="column in $ctrl.columns" ng-click="$ctrl.orderBy(column)" class="sortable-column">
{{column}} <span ng-if="$ctrl.sortIcon(column)"><i class="fa fa-sort-{{$ctrl.sortIcon(column)}}"></i></span>
{{column.title}} <span ng-if="$ctrl.sortIcon(column)"><i class="fa fa-sort-{{$ctrl.sortIcon(column)}}"></i></span>
</th>
</tr>

</thead>
<tbody>
<tr ng-repeat="row in $ctrl.rows">
<td ng-repeat="column in $ctrl.columns">
{{row[column]}}
{{column.formatFunction(row[column.name])}}
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/dynamic-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function DynamicTable() {
}

if (this.orderByField) {
this.allRows = sortBy(this.allRows, this.orderByField);
this.allRows = sortBy(this.allRows, this.orderByField.name);
if (this.orderByReverse) {
this.allRows = this.allRows.reverse();
}
Expand Down
24 changes: 7 additions & 17 deletions client/app/visualizations/table/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment';
import { each, isString, object, pluck } from 'underscore';
import { _, partial, isString } from 'underscore';
import { getColumnCleanName } from '../../services/query-result';
import template from './table.html';

Expand Down Expand Up @@ -62,23 +62,13 @@ function GridRenderer(clientConfig) {
$scope.filters = $scope.queryResult.getFilters();

const columns = $scope.queryResult.getColumns();
const columnsMap = object(pluck(columns, 'name'), pluck(columns, 'type'));
columns.forEach((col) => {
col.title = getColumnCleanName(col.name);
col.formatFunction = partial(formatValue, $filter, clientConfig, _, col.type);
});

const prepareGridData = (data) => {
const gridData = data.map((row) => {
const newRow = {};
each(row, (val, key) => {
const formattedValue = formatValue($filter, clientConfig, val, columnsMap[key]);
newRow[getColumnCleanName(key)] = formattedValue;
});
return newRow;
});

return gridData;
};

$scope.gridRows = prepareGridData($scope.queryResult.getData());
$scope.gridColumns = $scope.queryResult.getColumnCleanNames();
$scope.gridRows = $scope.queryResult.getData();
$scope.gridColumns = columns;
}
});
},
Expand Down
4 changes: 0 additions & 4 deletions redash/handlers/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ def post(self):
for field in ['id', 'created_at', 'api_key', 'visualizations', 'latest_query_data', 'last_modified_by']:
query_def.pop(field, None)

# If we already executed this query, save the query result reference
if 'latest_query_data_id' in query_def:
query_def['latest_query_data'] = query_def.pop('latest_query_data_id')

query_def['query_text'] = query_def.pop('query')
query_def['user'] = self.current_user
query_def['data_source'] = data_source
Expand Down