简体   繁体   English

Cube.js React QueryBuilder:如果月份在周中发生变化,则“本月”和“每周”不会从本周开始获取数据

[英]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.

相关问题 获取当前周/月的日期反应 useEffect - Getting dates of current week/month react useEffect FullCalendar (React) - 获取当前周/月的日期 - FullCalendar (React) - getting dates of current week/month Moment.js - 如何获取给定月份的每周数据[每周的开始日期和结束日期],不包括上个月和下个月的日期 - Moment.js - How to get weekly data [startDate & endDate of each week] for given month excluding previous and next month date React 从给定月份获取日历周数 - React Get Calendar Week Numbers from given month 提供新的 timeDimensions 时,Cube.js QueryBuilder 不会重新渲染 - Cube.js QueryBuilder does not rerender when new timeDimensions provided React 管理员日期过滤器(今天,本周,上周,本月,上个月) - React Admin Date Filter (Today, This Week, Last Week, This Month, Last Month) 使用 Cube.js 持久化数据 - Persist data using Cube.js 从每月或每周或每天或议程更改视图会使应用程序对大日历做出反应 - Changing view from month to week or day or agenda crashes the app react big calendar 如何获取下周的月、周、日格式列表? - how to get month, week , day format list of next week? 在datepicker react js中禁用与开始日期不同的月份 - Disable different month from start date in datepicker react js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM