Skip to content

Commit

Permalink
[FIX] pivot: date time measures are not supported
Browse files Browse the repository at this point in the history
Steps to reproduce:

- add a list of data in a spreadsheet, with at least one datetime field
- add a pivot based on this range
- add the data field as a measure
=> boom

Since 8421a73, all "date" fields are now "datetime".

closes #5060

Task: 4241036
Signed-off-by: Pierre Rousseau (pro) <[email protected]>
  • Loading branch information
LucasLefevre committed Oct 9, 2024
1 parent 7dfcb2a commit 2a83a3e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/pivot/pivot_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ pivotRegistry.add("SPREADSHEET", {
onIterationEndEvaluation: (pivot: SpreadsheetPivot) => pivot.markAsDirtyForEvaluation(),
dateGranularities: [...dateGranularities],
datetimeGranularities: [...dateGranularities, "hour_number", "minute_number", "second_number"],
isMeasureCandidate: (field: PivotField) => !["date", "boolean"].includes(field.type),
isMeasureCandidate: (field: PivotField) => !["datetime", "boolean"].includes(field.type),
isGroupable: () => true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,29 @@ describe("Spreadsheet pivot side panel", () => {
expect(fixture.querySelectorAll(".pivot-dimension")).toHaveLength(0);
});

test("filter unsupported measures", async () => {
setCellContent(model, "A1", "integer");
setCellContent(model, "A2", "10");
setCellContent(model, "B1", "float");
setCellContent(model, "B2", "10.1");
setCellContent(model, "C1", "bool");
setCellContent(model, "C2", "true");
setCellContent(model, "D1", "date");
setCellContent(model, "D2", "2024/01/01");
setCellContent(model, "E1", "datetime");
setCellContent(model, "E2", "2024/01/01 08:00:00");
setCellContent(model, "F1", "text");
setCellContent(model, "F2", "hi");
addPivot(model, "A1:F2", {}, "3");
env.openSidePanel("PivotSidePanel", { pivotId: "3" });
await nextTick();
await click(fixture.querySelector(".o-pivot-measure .add-dimension")!);
const measures = [...fixture.querySelectorAll(".o-autocomplete-value")].map(
(el) => el.textContent
);
expect(measures).toEqual(["Count", "float", "integer", "text"]);
});

test("Measures have the correct default aggregator", async () => {
setCellContent(model, "A1", "amount");
setCellContent(model, "A2", "10");
Expand Down

0 comments on commit 2a83a3e

Please sign in to comment.