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: cache param for expression dimension items (DHIS2-13871) #1433

Merged

Conversation

janhenrikoverland
Copy link
Collaborator

@janhenrikoverland janhenrikoverland commented Feb 21, 2023

Implements a small part of DHIS2-13871

  • hash creates a deterministic fixed-length hash of the input string, it's a separate function with its own test to make it easy to replace the hash function later
  • getHash accepts a string or an array of strings and returns the hash produced by hash
  • getExpressionHashFromVisualization grabs the expressions (looks for dimensionItemType and expression), if any EDIs in the visualization, then sorts them by id to get a cache hit as often as possible (now the order of the selected EDI items doesn't matter), and returns the result from getHash

In AnalyticsRequest we add the hash as a param edi_cache if there are EDIs in the visualization.

@janhenrikoverland janhenrikoverland changed the base branch from master to feat/DHIS2-13871-custom-calculations February 22, 2023 11:19
@janhenrikoverland janhenrikoverland marked this pull request as ready for review February 22, 2023 11:19
@@ -6,6 +6,8 @@ export const DIMENSION_TYPE_DATA_ELEMENT = 'DATA_ELEMENT'
export const DIMENSION_TYPE_DATA_SET = 'DATA_SET'
export const DIMENSION_TYPE_EVENT_DATA_ITEM = 'EVENT_DATA_ITEM'
export const DIMENSION_TYPE_PROGRAM_INDICATOR = 'PROGRAM_INDICATOR'
export const DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM =
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

image
It's on a different line though (I put it last), should be easy enough to detect if we end up with duplicates though

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved it to the same line, but still not picked up.

@janhenrikoverland janhenrikoverland merged commit 25be1f9 into feat/DHIS2-13871-custom-calculations Feb 27, 2023
@janhenrikoverland janhenrikoverland deleted the feat/edi-caching branch February 27, 2023 10:45
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