Skip to content

Commit

Permalink
Merge pull request #7038 from davidwatkins73/waltz-7037-grid-stat-vals
Browse files Browse the repository at this point in the history
Report Grids: entity stats have view options
  • Loading branch information
kamransaleem authored Mar 21, 2024
2 parents 2c73f8a + 8278ce7 commit 1c4781b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2284,50 +2284,62 @@ private Set<ReportGridCell> fetchEntityStatisticData(GenericSelector selector,
if (isEmpty(cols)) {
return emptySet();
} else {
Map<Long, Long> statisticDefinitionIdToColIdMap = indexBy(
Map<Long, ReportGridFixedColumnDefinition> statisticDefinitionIdToColMap = indexBy(
cols,
ReportGridFixedColumnDefinition::columnEntityId,
ReportGridFixedColumnDefinition::gridColumnId);
ReportGridFixedColumnDefinition::columnEntityId);

return dsl
.select(esv.ENTITY_ID,
esv.STATISTIC_ID,
esv.OUTCOME,
esv.VALUE,
esv.REASON)
.from(esv)
.where(esv.STATISTIC_ID.in(statisticDefinitionIdToColIdMap.keySet())
.where(esv.STATISTIC_ID.in(statisticDefinitionIdToColMap.keySet())
.and(esv.CURRENT.eq(true))
.and(esv.ENTITY_KIND.eq(selector.kind().name()))
.and(esv.ENTITY_ID.in(selector.selector())))
.orderBy(esv.OUTCOME)
.fetchGroups(
r -> tuple(
r.get(esv.ENTITY_ID),
statisticDefinitionIdToColIdMap.get(r.get(esv.STATISTIC_ID))),
statisticDefinitionIdToColMap.get(r.get(esv.STATISTIC_ID))),
r -> tuple(
r.get(esv.OUTCOME),
r.get(esv.VALUE),
r.get(esv.REASON)))
.entrySet()
.stream()
.map(kv -> {
Tuple2<Long, ReportGridFixedColumnDefinition> cellKey = kv.getKey();
List<Tuple3<String, String, String>> cellValues = kv.getValue();

String outcomeString = kv.getValue()
String outcomeString = cellValues
.stream()
.map(t -> t.v1)
.sorted(comparing(StringUtilities::lower))
.sorted(comparing(t -> StringUtilities.lower(t.v1)))
.map(t -> {
AdditionalColumnOptions opts = cellKey.v2.additionalColumnOptions();
if (opts == AdditionalColumnOptions.VALUES_ONLY) {
return t.v2;
} else if (opts == AdditionalColumnOptions.VALUES_AND_OUTCOMES) {
return String.format("%s = %s", t.v1, t.v2);
} else {
return t.v1;
}
})
.collect(joining("; "));

List<Tuple2<String, String>> rowsInComment = CollectionUtilities.sort(
kv.getValue(),
List<Tuple3<String, String, String>> rowsInComment = CollectionUtilities.sort(
cellValues,
comparing(t -> lower(safeTrim(t.v1))));

return ImmutableReportGridCell
.builder()
.subjectId(kv.getKey().v1)
.columnDefinitionId(kv.getKey().v2)
.subjectId(cellKey.v1)
.columnDefinitionId(cellKey.v2.gridColumnId())
.textValue(outcomeString)
.comment(toHtmlTable(
asList("Outcome", "Reason"),
asList("Outcome", "Value", "Reason"),
rowsInComment))
.build();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public enum AdditionalColumnOptions {
ROLLUP(asSet(EntityKind.DATA_TYPE)),
COMPLETED_AND_APPROVED_ONLY(asSet(EntityKind.SURVEY_INSTANCE, EntityKind.SURVEY_QUESTION)),
EXCLUDE_WITHDRAWN(asSet(EntityKind.SURVEY_INSTANCE, EntityKind.SURVEY_QUESTION)),
PRIMARY(asSet(EntityKind.MEASURABLE));
PRIMARY(asSet(EntityKind.MEASURABLE)),
VALUES_ONLY(asSet(EntityKind.ENTITY_STATISTIC)),
VALUES_AND_OUTCOMES(asSet(EntityKind.ENTITY_STATISTIC));


private final Set<EntityKind> allowedKinds;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@
class="clickable waltz-visibility-parent"
class:isActiveFilter={isActive($activeSummaries, summary)}>
<td>
<span class="waltz-visibility-child-30">
<Icon name={isActive($activeSummaries, summary) ? 'check' : 'arrow-left'}/>
</span>
<span class="waltz-visibility-child-30">
<Icon name={isActive($activeSummaries, summary) ? 'check' : 'arrow-left'}/>
</span>
<span class="column-name">
{getDisplayNameForColumn(summary.column)}
</span>
{getDisplayNameForColumn(summary.column)}
</span>
<ul style="display: inline-block"
class="list-inline column-values-summary">
{#each summary.optionSummaries as option}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ export const additionalColumnOptions = {
PRIMARY: {
key: "PRIMARY",
name: "Primary",
},
VALUES_ONLY: {
key: "VALUES_ONLY",
name: "Values Only",
},
VALUES_AND_OUTCOMES: {
key: "VALUES_AND_OUTCOMES",
name: "Values and Outcomes",
}
}

Expand Down

0 comments on commit 1c4781b

Please sign in to comment.