[GroupBy] Fix order by date granularity (#17573)

https://discord.com/channels/1130383047699738754/1466472357496623165/1466472357496623165

before
<img width="1262" height="598" alt="image"
src="https://github.com/user-attachments/assets/e6fb9a13-58c0-408d-b3e9-a486ec04c33c"
/>

after
<img width="670" height="267" alt="image"
src="https://github.com/user-attachments/assets/b4b5ab19-1144-4300-9801-b8220ce928f9"
/>
This commit is contained in:
Marie
2026-01-30 17:40:36 +01:00
committed by GitHub
parent ebc7125b20
commit 15b053de46
5 changed files with 242 additions and 23 deletions
@@ -51,8 +51,12 @@ const buildDateGroupByObject = ({
result.timeZone = timeZone;
}
const shouldIncludeWeekStartDay =
usedDateGranularity === ObjectRecordGroupByDateGranularity.WEEK ||
usedDateGranularity === ObjectRecordGroupByDateGranularity.DAY_OF_THE_WEEK;
if (
usedDateGranularity === ObjectRecordGroupByDateGranularity.WEEK &&
shouldIncludeWeekStartDay &&
isDefined(firstDayOfTheWeek) &&
firstDayOfTheWeek !== CalendarStartDay.SYSTEM
) {
@@ -49,10 +49,11 @@ export const compareDimensionValues = ({
direction === 'ASC' ? comparison : -comparison;
if (isDefined(fieldType)) {
if (
isFieldMetadataDateKind(fieldType) &&
!isCyclicalDateGranularity(dateGranularity)
) {
if (isFieldMetadataDateKind(fieldType)) {
if (isCyclicalDateGranularity(dateGranularity)) {
return 0;
}
const dateA = parseDate(rawValueA);
const dateB = parseDate(rawValueB);