Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

BRaimbault
Copy link
Contributor

@BRaimbault BRaimbault commented Nov 25, 2024

Implements DHIS2-15796

Relates to dhis2/maps-app#3407


Key features

  1. PeriodDimension component to accept a height prop.
  2. fixedPeriods utils to export regex patterns for period type identification.
  3. New utility functions for relativePeriods in order to get relative period names and details.

Description

1. PeriodDimension

  • PeriodTransfer component to accept a height prop (defaults to TRANSFER_HEIGHT ie. original behavior).
  • PeriodDimension component to accept a height prop to pass to PeriodTransfer.

2. fixedPeriods utils

Export PERIOD_TYPE_REGEX from fixedPeriods utils to be used for period type identification.

3. relativePeriods utils

  • Added new duration and offset properties to getDaysPeriodType, getWeeksPeriodType, getBiWeeksPeriodType, getBiWeeksPeriodType, getMonthsPeriodType, getBiMonthsPeriodType, getQuartersPeriodType, getSixMonthsPeriodType, getFinancialYearsPeriodType, and getYearsPeriodType. These allow for estimation of number of periods that will be returned in an analytics query when overlapping period presets are selected.
  • Added new getRelativePeriodsDetails function that returns an object with relative period presets ids as keys and all their associated details (id, name, offset, duration and type) in an object as values, this across all period types (DAILY, WEEKLY...).
  • Added new getRelativePeriodsName function that returns an object with relative period presets ids as keys and names as values, this across all period types (DAILY, WEEKLY...).

@BRaimbault BRaimbault changed the title feat: add flexibimity to PeriodDimension and associated utils feat: add flexibility to PeriodDimension and associated utils Dec 4, 2024
{ 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 },
Copy link
Collaborator

@jenniferarnesen jenniferarnesen Jan 2, 2025

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, see snippet below:

/*
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
@BRaimbault BRaimbault marked this pull request as ready for review January 7, 2025 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants