-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add flexibility to PeriodDimension and associated utils #1735
base: master
Are you sure you want to change the base?
Conversation
{ id: 'LAST_60_DAYS', name: i18n.t('Last 60 days') }, | ||
{ id: 'LAST_90_DAYS', name: i18n.t('Last 90 days') }, | ||
{ id: 'LAST_180_DAYS', name: i18n.t('Last 180 days') }, | ||
{ id: 'TODAY', name: i18n.t('Today'), offset: 0, duration: 1 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a file comment explaining what offset
is? Also, while you're at it, you could clarify duration
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, see snippet below:
analytics/src/components/PeriodDimension/utils/relativePeriods.js
Lines 15 to 27 in 6bf23fd
/* | |
In getDaysPeriodType, getWeeksPeriodType, getBiWeeksPeriodType, | |
getBiWeeksPeriodType, getMonthsPeriodType, getBiMonthsPeriodType, | |
getQuartersPeriodType, getSixMonthsPeriodType, | |
getFinancialYearsPeriodType, and getYearsPeriodType: | |
- duration: The number of individual periods in the preset | |
(the maximum when the duration is variable). | |
eg: LAST_14_DAYS duration is 14 | |
- offset: The position of the most recent individual period | |
relative to THIS period in the preset, earlier periods are | |
negative (the maximum when the offset is variable). | |
eg: LAST_BIMONTH offset is -1 | |
*/ |
Do you think it is clear enough? And the property names are well chosen?
- add tests to getRelativePeriodsDetails and getRelativePeriodsName - add description for duration and offset properties
Implements DHIS2-15796
Relates to dhis2/maps-app#3407
Key features
PeriodDimension
component to accept aheight
prop.fixedPeriods
utils to export regex patterns for period type identification.relativePeriods
in order to get relative period names and details.Description
1.
PeriodDimension
PeriodTransfer
component to accept aheight
prop (defaults toTRANSFER_HEIGHT
ie. original behavior).PeriodDimension
component to accept aheight
prop to pass toPeriodTransfer
.2.
fixedPeriods
utilsExport
PERIOD_TYPE_REGEX
fromfixedPeriods
utils to be used for period type identification.3.
relativePeriods
utilsduration
andoffset
properties togetDaysPeriodType
,getWeeksPeriodType
,getBiWeeksPeriodType
,getBiWeeksPeriodType
,getMonthsPeriodType
,getBiMonthsPeriodType
,getQuartersPeriodType
,getSixMonthsPeriodType
,getFinancialYearsPeriodType
, andgetYearsPeriodType
. These allow for estimation of number of periods that will be returned in an analytics query when overlapping period presets are selected.getRelativePeriodsDetails
function that returns an object with relative period presets ids as keys and all their associated details (id
,name
,offset
,duration
andtype
) in an object as values, this across all period types (DAILY
,WEEKLY
...).getRelativePeriodsName
function that returns an object with relative period presets ids as keys and names as values, this across all period types (DAILY
,WEEKLY
...).