mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-01 19:18:05 +00:00
Fix messages and percentages in Data Insight reports (#14731)
This commit is contained in:
parent
6620389ad1
commit
bfbd953b53
@ -247,26 +247,22 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
|
||||
double currentCompletedDescription = getCompletedDescriptionCount(last);
|
||||
double currentTotalCount = getTotalEntityFromDescriptionList(last);
|
||||
|
||||
// Calculate Percent Change
|
||||
double previousDiff = previousTotalCount - previousCompletedDescription;
|
||||
double currentDiff = currentTotalCount - currentCompletedDescription;
|
||||
|
||||
// Change
|
||||
double percentChange = 0D;
|
||||
if (previousDiff != 0) {
|
||||
percentChange = ((currentDiff - previousDiff) / previousDiff) * 100;
|
||||
// Previous Percent
|
||||
double previousPercentCompleted = 0D;
|
||||
if (previousTotalCount != 0) {
|
||||
previousPercentCompleted = (previousCompletedDescription / previousTotalCount) * 100;
|
||||
}
|
||||
// Completion
|
||||
double percentCompleted = 0;
|
||||
// Current Percent
|
||||
double currentPercentCompleted = 0;
|
||||
if (currentTotalCount != 0) {
|
||||
percentCompleted = (currentCompletedDescription / currentTotalCount) * 100;
|
||||
currentPercentCompleted = (currentCompletedDescription / currentTotalCount) * 100;
|
||||
}
|
||||
|
||||
return getTemplate(
|
||||
DataInsightDescriptionAndOwnerTemplate.MetricType.DESCRIPTION,
|
||||
PERCENTAGE_OF_ENTITIES_WITH_DESCRIPTION_BY_TYPE,
|
||||
percentCompleted,
|
||||
percentChange,
|
||||
currentPercentCompleted,
|
||||
currentPercentCompleted - previousPercentCompleted,
|
||||
numberOfDaysChange);
|
||||
}
|
||||
|
||||
@ -300,27 +296,22 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
|
||||
double currentHasOwner = getCompletedOwnershipCount(last);
|
||||
double currentTotalCount = getTotalEntityFromOwnerList(last);
|
||||
|
||||
// Calculate Change
|
||||
double previousDiff = previousTotalCount - previousHasOwner;
|
||||
double currentDiff = currentTotalCount - currentHasOwner;
|
||||
|
||||
// Change Percent
|
||||
double percentChange = 0D;
|
||||
if (previousDiff != 0) {
|
||||
percentChange = ((currentDiff - previousDiff) / previousDiff) * 100;
|
||||
// Previous Percent
|
||||
double previousPercentCompleted = 0D;
|
||||
if (previousTotalCount != 0) {
|
||||
previousPercentCompleted = (previousHasOwner / previousTotalCount) * 100;
|
||||
}
|
||||
|
||||
// Completion
|
||||
double percentCompleted = 0;
|
||||
// Current Percent
|
||||
double currentPercentCompleted = 0;
|
||||
if (currentTotalCount != 0) {
|
||||
percentCompleted = (currentHasOwner / currentTotalCount) * 100;
|
||||
currentPercentCompleted = (currentHasOwner / currentTotalCount) * 100;
|
||||
}
|
||||
|
||||
return getTemplate(
|
||||
DataInsightDescriptionAndOwnerTemplate.MetricType.OWNER,
|
||||
PERCENTAGE_OF_ENTITIES_WITH_OWNER_BY_TYPE,
|
||||
percentCompleted,
|
||||
percentChange,
|
||||
currentPercentCompleted,
|
||||
currentPercentCompleted - previousPercentCompleted,
|
||||
numberOfDaysChange);
|
||||
}
|
||||
|
||||
@ -479,28 +470,23 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
|
||||
private long getTimeFromSchedule(
|
||||
AppSchedule appSchedule, JobExecutionContext jobExecutionContext) {
|
||||
AppSchedule.ScheduleTimeline timeline = appSchedule.getScheduleType();
|
||||
switch (timeline) {
|
||||
case HOURLY:
|
||||
return 3600000L;
|
||||
case DAILY:
|
||||
return 86400000L;
|
||||
case WEEKLY:
|
||||
return 604800000L;
|
||||
case MONTHLY:
|
||||
return 2592000000L;
|
||||
case CUSTOM:
|
||||
return switch (timeline) {
|
||||
case HOURLY -> 3600000L;
|
||||
case DAILY -> 86400000L;
|
||||
case WEEKLY -> 604800000L;
|
||||
case MONTHLY -> 2592000000L;
|
||||
case CUSTOM -> {
|
||||
if (jobExecutionContext.getTrigger() != null) {
|
||||
Trigger triggerQrz = jobExecutionContext.getTrigger();
|
||||
Date previousFire =
|
||||
triggerQrz.getPreviousFireTime() == null
|
||||
? triggerQrz.getStartTime()
|
||||
: triggerQrz.getPreviousFireTime();
|
||||
return previousFire.toInstant().toEpochMilli();
|
||||
yield previousFire.toInstant().toEpochMilli();
|
||||
}
|
||||
return 86400000L;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid Trigger Type.");
|
||||
}
|
||||
yield 86400000L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static int getNumberOfDays(AppSchedule appSchedule) {
|
||||
|
||||
@ -28,9 +28,9 @@ public class DataInsightDescriptionAndOwnerTemplate {
|
||||
NOT_MET
|
||||
}
|
||||
|
||||
private final Double percentCompleted;
|
||||
private final String percentCompleted;
|
||||
private boolean kpiAvailable;
|
||||
private Double percentChange;
|
||||
private String percentChange;
|
||||
private String targetKpi;
|
||||
private String numberOfDaysLeft;
|
||||
private String completeMessage;
|
||||
@ -47,9 +47,9 @@ public class DataInsightDescriptionAndOwnerTemplate {
|
||||
String numberOfDaysLeft,
|
||||
int numberOfDaysChange,
|
||||
Map<String, Double> tierMap) {
|
||||
this.percentCompleted = percentCompleted;
|
||||
this.percentCompleted = String.format("%.2f", percentCompleted);
|
||||
this.targetKpi = targetKpi;
|
||||
this.percentChange = percentChange;
|
||||
this.percentChange = String.format("%.2f", percentChange);
|
||||
this.kpiAvailable = isKpiAvailable;
|
||||
this.numberOfDaysLeft = numberOfDaysLeft;
|
||||
this.tierMap = tierMap;
|
||||
@ -60,10 +60,10 @@ public class DataInsightDescriptionAndOwnerTemplate {
|
||||
}
|
||||
this.completeMessage =
|
||||
String.format(
|
||||
"The %s changed by <strong style=\"color: %s;\">%.2f%%</strong> per cent in the last week. %s",
|
||||
"The %s changed by <strong style=\"color: %s;\">%s</strong>%% in the last week. %s",
|
||||
getMetricTypeMessage(metricType),
|
||||
color,
|
||||
percentChange,
|
||||
this.percentChange,
|
||||
getKpiCriteriaMessage(metricType, criteria));
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ public class DataInsightDescriptionAndOwnerTemplate {
|
||||
return switch (criteria) {
|
||||
case MET -> "Great the Target Set for KPIs has been achieved. It's time to restructure your goals, set new KPIs and progress faster.";
|
||||
case IN_PROGRESS -> String.format(
|
||||
"To meet the KPIs you will need a minimum of %s per cent completed description in the next %s days.",
|
||||
targetKpi, numberOfDaysLeft);
|
||||
"To meet the KPIs you will need a minimum of %s%% %s in the next %s days.",
|
||||
targetKpi, getMetricTypeMessage(metricType).toLowerCase(), numberOfDaysLeft);
|
||||
case NOT_MET -> "The Target set for KPIs was not met it’s time to restructure your goals and progress faster.";
|
||||
};
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class DataInsightDescriptionAndOwnerTemplate {
|
||||
return "";
|
||||
}
|
||||
|
||||
public Double getPercentCompleted() {
|
||||
public String getPercentCompleted() {
|
||||
return percentCompleted;
|
||||
}
|
||||
|
||||
@ -103,12 +103,12 @@ public class DataInsightDescriptionAndOwnerTemplate {
|
||||
this.targetKpi = targetKpi;
|
||||
}
|
||||
|
||||
public Double getPercentChange() {
|
||||
public String getPercentChange() {
|
||||
return percentChange;
|
||||
}
|
||||
|
||||
public void setPercentChange(Double percentChange) {
|
||||
this.percentChange = percentChange;
|
||||
this.percentChange = String.format("%.2f", percentChange);
|
||||
}
|
||||
|
||||
public boolean isKpiAvailable() {
|
||||
|
||||
@ -14,16 +14,15 @@
|
||||
package org.openmetadata.service.events.scheduled.template;
|
||||
|
||||
public class DataInsightTotalAssetTemplate {
|
||||
private Double totalDataAssets;
|
||||
private Double percentChangeTotalAssets;
|
||||
private String totalDataAssets;
|
||||
private String percentChangeTotalAssets;
|
||||
private String completeMessage;
|
||||
|
||||
private int numberOfDaysChange;
|
||||
|
||||
public DataInsightTotalAssetTemplate(
|
||||
Double totalDataAssets, Double percentChangeTotalAssets, int numberOfDaysChange) {
|
||||
this.totalDataAssets = totalDataAssets;
|
||||
this.percentChangeTotalAssets = percentChangeTotalAssets;
|
||||
this.totalDataAssets = String.format("%.2f", totalDataAssets);
|
||||
this.percentChangeTotalAssets = String.format("%.2f", percentChangeTotalAssets);
|
||||
this.numberOfDaysChange = numberOfDaysChange;
|
||||
String color = "#BF0000";
|
||||
if (percentChangeTotalAssets > 0) {
|
||||
@ -31,24 +30,24 @@ public class DataInsightTotalAssetTemplate {
|
||||
}
|
||||
completeMessage =
|
||||
String.format(
|
||||
"In the past week, the Total Data Assets changed by a total of <span style=\"color: %s; font-weight: bold;\">%.2f%%</span>",
|
||||
color, percentChangeTotalAssets);
|
||||
"In the past week, the Total Data Assets changed by <span style=\"color: %s; font-weight: bold;\">%s</span>%%.",
|
||||
color, this.percentChangeTotalAssets);
|
||||
}
|
||||
|
||||
public Double getTotalDataAssets() {
|
||||
public String getTotalDataAssets() {
|
||||
return totalDataAssets;
|
||||
}
|
||||
|
||||
public void setTotalDataAssets(Double totalDataAssets) {
|
||||
this.totalDataAssets = totalDataAssets;
|
||||
this.totalDataAssets = String.format("%.2f", totalDataAssets);
|
||||
}
|
||||
|
||||
public Double getPercentChangeTotalAssets() {
|
||||
public String getPercentChangeTotalAssets() {
|
||||
return percentChangeTotalAssets;
|
||||
}
|
||||
|
||||
public void setPercentChangeTotalAssets(Double percentChangeTotalAssets) {
|
||||
this.percentChangeTotalAssets = percentChangeTotalAssets;
|
||||
this.percentChangeTotalAssets = String.format("%.2f", percentChangeTotalAssets);
|
||||
}
|
||||
|
||||
public String getCompleteMessage() {
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
"sendToTeams": true
|
||||
},
|
||||
"appSchedule": {
|
||||
"scheduleType": "Custom",
|
||||
"cronExpression": "0 59 23 ? * 1"
|
||||
"scheduleType": "Weekly"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user