Skip to content

Commit

Permalink
Merge pull request #1484 from getredash/v1fixes
Browse files Browse the repository at this point in the history
Fix #1457: sort was using the string value
  • Loading branch information
arikfr authored Dec 23, 2016
2 parents 3bc98fb + 40b8200 commit e0a010f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
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

0 comments on commit e0a010f

Please sign in to comment.