[英]Cube.js React QueryBuilder : "This month" and "Weekly" not getting data from start of week if month changes mid-week
I understand why "This month"
combined with "Weekly"
doesn't get the full week's data if the month starts at the middle.我理解如果月份从中间开始,为什么
"This month"
与"Weekly"
相结合无法获得整周的数据。 For example the week starting September 27th still shows as starting 2021-09-27
but the data is only taken from 2021-10-01
as the "This month"
filter is set, it makes sense but sometimes we would like to get the full week even if the month changed midweek but we don't want to set a broader filter ( "This quarter"
or even "This year"
are too many weeks to consider).例如,从 9 月 27 日开始的一周仍然显示为从
2021-09-27
开始,但数据仅从2021-10-01
获取,因为设置了"This month"
过滤器,这是有道理的,但有时我们希望获得完整的数据week 即使月份在周中更改,但我们不想设置更广泛的过滤器( "This quarter"
甚至"This year"
都需要考虑太多周)。 I tried tracing the TimeDimensions function back and ended at the "QueryBuilder"
component, on the "updateTimeDimensions"
but it's imported from '@cubejs-client/react'
so I cannot see what the component accepts as "Time Dimension"
or if you can add an option of "This month + full weeks"
.我尝试追踪 TimeDimensions function 并在
"updateTimeDimensions"
上的"QueryBuilder"
组件处结束,但它是from '@cubejs-client/react'
导入的,所以我看不到组件接受什么作为"Time Dimension"
或者如果你可以添加"This month + full weeks"
选项。 Does someone have any suggestion on how to make this work?有人对如何进行这项工作有任何建议吗?
you can always manipulate your dates in the front-end before feeding them to query time_dimensions.在将日期输入到查询 time_dimensions 之前,您始终可以在前端操作日期。
Define a function that takes your dateRange ['2021-10-1', '2021-10-31'] and returns a dateRange that includes weeks completed, that's possible with date-fns or moment.js or day.js.定义一个 function,它采用您的 dateRange ['2021-10-1', '2021-10-31'] 并返回一个包含已完成周数的 dateRange,这可以使用 date-fns 或 moment.js 或 day.js。 and call that function when you select 'Weekly'.
当您将 select 称为“每周”时,将其称为 function。
here is an imperative example :这是一个命令式的例子:
dateRange: any = [new Date('2021-10-1'), new Date('2021-10-31')];
startAndendWeeksIncluded = [
startOfWeek(this.dateRange[0], { weekStartsOn: 1 }),
endOfWeek(this.dateRange[1], { weekStartsOn: 1 }),
];
//OutPut ["2021-09-26T23:00:00.000Z", "2021-10-31T22:59:59.999Z"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.