Skip to content
Snippets Groups Projects
Commit 8e3df5d1 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #2572 from metabase/frontend-date-sort-fix

Don't use datetime_field for sorting. Don't render unit if there is none
parents 75c14a17 7a680ad6
No related branches found
No related tags found
No related merge requests found
......@@ -182,8 +182,6 @@ CardControllers.controller('CardDetail', [
} else {
field = ["aggregation", 0];
}
} else if (column.unit != null) {
field = ["datetime_field", column.id, "as", column.unit];
} else {
field = column.id;
}
......
......@@ -10,7 +10,7 @@ export function computeFilterTimeRange(filter) {
}
let [operator, field, ...values] = expandedFilter;
let bucketing = parseFieldBucketing(field);
let bucketing = parseFieldBucketing(field, "day");
let start, end;
if (operator === "=" && values[0]) {
......@@ -146,17 +146,17 @@ export function absolute(date) {
}
}
export function parseFieldBucketing(field) {
export function parseFieldBucketing(field, defaultUnit = null) {
if (Array.isArray(field)) {
if (field[0] === "datetime_field") {
return field[3];
} if (field[0] === "fk->") {
return "day";
return defaultUnit;
} else {
console.warn("Unknown field format", field);
}
}
return "day";
return defaultUnit;
}
export function parseFieldTarget(field) {
......
......@@ -143,7 +143,7 @@ export default class FieldList extends Component {
renderTimeGroupingTrigger(field) {
return (
<div className="FieldList-grouping-trigger flex align-center p1 cursor-pointer">
<h4 className="mr1">by {parseFieldBucketing(field).split("-").join(" ")}</h4>
<h4 className="mr1">by {parseFieldBucketing(field, "day").split("-").join(" ")}</h4>
<Icon name="chevronright" width={16} height={16} />
</div>
);
......
......@@ -4,7 +4,6 @@ import Icon from "metabase/components/Icon.jsx";
import Query from "metabase/lib/query";
import { formatBucketing, parseFieldBucketing, parseFieldTarget } from "metabase/lib/query_time";
import { isDate } from "metabase/lib/schema_metadata";
import { stripId } from "metabase/lib/formatting";
import _ from "underscore";
......@@ -54,7 +53,7 @@ export default class FieldName extends Component {
}
// if this is a datetime field then add an extra bit of labeling about the time bucket
if (fieldDef && isDate(fieldDef)) {
if (fieldDef && bucketing) {
bucketingTitle = ": " + formatBucketing(bucketing);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment