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

Analytics API: Add Options aggregation and disaggregation #19111

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

d-bernat
Copy link
Contributor

@d-bernat d-bernat commented Nov 9, 2024

TBD

Copy link

sonarcloud bot commented Nov 9, 2024

@@ -861,6 +867,17 @@ public boolean isOutputFormat(OutputFormat format) {
return this.outputFormat != null && this.outputFormat == format;
}

public boolean hasOptionSetInDimensionItems() {
return dimensions.stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, simplify this logic by using less streams.

// choose options from an option set and display those as disaggregated data items.
// This selection is non-relative and will not automatically include
// any options added to the option set in the future.
ABSOLUTE;
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not understand the ABSOLUTE... We need to cover only AGGREGATED and DISAGGREGATED params.

private static final Pattern COMPOSITE_DIM_OBJECT_PATTERN =
Pattern.compile("(?<id1>\\w+)\\.(?<id2>\\w+|\\*)(\\.(?<id3>\\w+|\\*))?");
Pattern.compile(
"(?<id1>\\w+)\\.(?<id2>\\w+|\\*)(\\.(?<id3>\\w+|\\*))?(-?(?<suffix>AGGREGATED|DISAGGREGATED|ABSOLUTE)?)?");
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, what's the purpose of accepting ABSOLUTE?

@@ -751,6 +757,24 @@ protected String getAggregateClause(EventQueryParams params) {
}
}

private AggregationType getAggregationType(EventQueryParams params) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Do not need this blank line.

@@ -751,6 +757,24 @@ protected String getAggregateClause(EventQueryParams params) {
}
}

private AggregationType getAggregationType(EventQueryParams params) {

if (params.getValue() instanceof DataElement
Copy link
Contributor

Choose a reason for hiding this comment

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

We can write it cleaner.
This seems too much to be inside an IF statement:

params
                .getOptionSetSelectionCriteria()
                .getOptionSetSelectionModes()
                .get(
                    params.getValue().getUid()
                        + "."
                        + ((DataElement) params.getValue()).getOptionSet().getUid()

@@ -90,6 +90,13 @@ public List<EventQueryParams> planAggregateQuery(EventQueryParams params) {
return withTableNameAndPartitions(queries);
}

@Override
public List<EventQueryParams> planQuery(EventQueryParams params) {
List<EventQueryParams> queries = Lists.newArrayList(params);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use plain Java instead of the Guava API?

@@ -105,6 +105,8 @@
@Slf4j
@Service("org.hisp.dhis.analytics.AnalyticsTableManager")
public class JdbcAnalyticsTableManager extends AbstractJdbcTableManager {
// deo.optionsetuid as optionsetuid,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not forget to clean-up it.


OptionSet optionSet = dataElement.getOptionSet();
if (optionSet != null) {
map.put(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, make it more readable. Create the variables (key/value) before adding to the map, so we can have map.put(key, value);

@larshelge larshelge changed the title Analytics API: Add support for Options aggregation and disaggregation. Analytics API: Add Options aggregation and disaggregation Nov 25, 2024
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