Fixes #15686 : Updated Data Insights Report Schema (#15705)

This commit is contained in:
Mohit Yadav 2024-03-26 23:53:30 +05:30 committed by GitHub
parent 9d7bfa363e
commit f5a459bce6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 198 additions and 35 deletions

View File

@ -294,6 +294,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
PERCENTAGE_OF_ENTITIES_WITH_DESCRIPTION_BY_TYPE,
currentPercentCompleted,
currentPercentCompleted - previousPercentCompleted,
(int) currentCompletedDescription,
numberOfDaysChange,
dateMap);
}
@ -303,6 +304,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
PERCENTAGE_OF_ENTITIES_WITH_DESCRIPTION_BY_TYPE,
0D,
0D,
0,
numberOfDaysChange,
dateMap);
}
@ -362,6 +364,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
PERCENTAGE_OF_ENTITIES_WITH_OWNER_BY_TYPE,
currentPercentCompleted,
currentPercentCompleted - previousPercentCompleted,
(int) currentHasOwner,
numberOfDaysChange,
dateMap);
}
@ -370,6 +373,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
PERCENTAGE_OF_ENTITIES_WITH_OWNER_BY_TYPE,
0D,
0D,
0,
numberOfDaysChange,
dateMap);
}
@ -408,6 +412,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
return new DataInsightDescriptionAndOwnerTemplate(
DataInsightDescriptionAndOwnerTemplate.MetricType.TIER,
null,
"0",
0D,
KPI_NOT_SET,
0D,
@ -421,6 +426,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
return new DataInsightDescriptionAndOwnerTemplate(
DataInsightDescriptionAndOwnerTemplate.MetricType.TIER,
null,
"0",
0D,
KPI_NOT_SET,
0D,
@ -503,6 +509,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
DataInsightChartResult.DataInsightChartType chartType,
Double percentCompleted,
Double percentChange,
int totalAssets,
int numberOfDaysChange,
Map<String, Integer> dateMap) {
@ -524,8 +531,8 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
if (isKpiAvailable) {
targetKpi =
String.valueOf(
Double.parseDouble(validKpi.getTargetDefinition().get(0).getValue()) * 100);
String.format(
"%.2f", Double.parseDouble(validKpi.getTargetDefinition().get(0).getValue()) * 100);
KpiResult result = getKpiResult(validKpi.getName());
if (result != null) {
isTargetMet = result.getTargetResult().get(0).getTargetMet();
@ -546,6 +553,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication {
return new DataInsightDescriptionAndOwnerTemplate(
metricType,
criteria,
String.valueOf(totalAssets),
percentCompleted,
targetKpi,
percentChange,

View File

@ -29,9 +29,11 @@ public class DataInsightDescriptionAndOwnerTemplate {
NOT_MET
}
private String totalAssets;
private final String percentCompleted;
private boolean kpiAvailable;
private String percentChange;
private String percentChangeMessage;
private String targetKpi;
private String numberOfDaysLeft;
private String completeMessage;
@ -42,6 +44,7 @@ public class DataInsightDescriptionAndOwnerTemplate {
public DataInsightDescriptionAndOwnerTemplate(
MetricType metricType,
KpiCriteria criteria,
String totalAssets,
Double percentCompleted,
String targetKpi,
Double percentChange,
@ -53,6 +56,8 @@ public class DataInsightDescriptionAndOwnerTemplate {
this.percentCompleted = String.format("%.2f", percentCompleted);
this.targetKpi = targetKpi;
this.percentChange = String.format("%.2f", percentChange);
this.percentChangeMessage = getFormattedPercentChangeMessage(percentChange);
this.totalAssets = totalAssets;
this.kpiAvailable = isKpiAvailable;
this.numberOfDaysLeft = numberOfDaysLeft;
this.tierMap = tierMap;
@ -131,6 +136,22 @@ public class DataInsightDescriptionAndOwnerTemplate {
this.numberOfDaysLeft = numberOfDaysLeft;
}
public String getTotalAssets() {
return totalAssets;
}
public void setTotalAssets(String totalAssets) {
this.totalAssets = totalAssets;
}
public String getPercentChangeMessage() {
return percentChangeMessage;
}
public void setPercentChangeMessage(String message) {
this.percentChangeMessage = message;
}
public String getCompleteMessage() {
return completeMessage;
}
@ -162,4 +183,18 @@ public class DataInsightDescriptionAndOwnerTemplate {
public void setDateMap(Map<String, Integer> dateMap) {
this.dateMap = dateMap;
}
public static String getFormattedPercentChangeMessage(Double percent) {
String symbol = "";
String color = "#BF0000";
if (percent > 0) {
symbol = "+";
color = "#008611";
} else if (percent < 0) {
symbol = "-";
}
return String.format(
"<span style=\"color:%s ; font-weight: 600\">%s%.2f</span>", color, symbol, percent);
}
}

View File

@ -13,12 +13,15 @@
package org.openmetadata.service.events.scheduled.template;
import static org.openmetadata.service.events.scheduled.template.DataInsightDescriptionAndOwnerTemplate.getFormattedPercentChangeMessage;
import java.util.Map;
@SuppressWarnings("unused")
public class DataInsightTotalAssetTemplate {
private String totalDataAssets;
private String percentChangeTotalAssets;
private String percentChangeMessage;
private String completeMessage;
private int numberOfDaysChange;
private Map<String, Integer> dateMap;
@ -30,6 +33,7 @@ public class DataInsightTotalAssetTemplate {
Map<String, Integer> dateMap) {
this.totalDataAssets = String.format("%.2f", totalDataAssets);
this.percentChangeTotalAssets = String.format("%.2f", percentChangeTotalAssets);
this.percentChangeMessage = getFormattedPercentChangeMessage(percentChangeTotalAssets);
this.numberOfDaysChange = numberOfDaysChange;
this.dateMap = dateMap;
String color = "#BF0000";
@ -66,6 +70,14 @@ public class DataInsightTotalAssetTemplate {
this.completeMessage = completeMessage;
}
public String getPercentChangeMessage() {
return percentChangeMessage;
}
public void setPercentChangeMessage(String message) {
this.percentChangeMessage = message;
}
public int getNumberOfDaysChange() {
return numberOfDaysChange;
}

View File

@ -20,6 +20,7 @@ import org.openmetadata.schema.type.ProviderType;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.service.Entity;
import org.openmetadata.service.exception.EntityNotFoundException;
import org.openmetadata.service.exception.UnhandledServerException;
import org.openmetadata.service.resources.apps.AppResource;
import org.openmetadata.service.security.jwt.JWTTokenGenerator;
import org.openmetadata.service.util.EntityUtil;
@ -209,6 +210,9 @@ public class AppRepository extends EntityRepository<App> {
public AppRunRecord getLatestAppRuns(UUID appId) {
String json = daoCollection.appExtensionTimeSeriesDao().getLatestAppRun(appId);
if (json == null) {
throw new UnhandledServerException("No Available Application Run Records.");
}
return JsonUtils.readValue(json, AppRunRecord.class);
}

View File

@ -122,7 +122,6 @@ import org.openmetadata.schema.util.EntitiesCount;
import org.openmetadata.schema.util.ServicesCount;
import org.openmetadata.schema.utils.EntityInterfaceUtil;
import org.openmetadata.service.Entity;
import org.openmetadata.service.exception.UnhandledServerException;
import org.openmetadata.service.jdbi3.CollectionDAO.TagUsageDAO.TagLabelMapper;
import org.openmetadata.service.jdbi3.CollectionDAO.UsageDAO.UsageDetailsMapper;
import org.openmetadata.service.jdbi3.FeedRepository.FilterType;
@ -3715,7 +3714,7 @@ public interface CollectionDAO {
if (!nullOrEmpty(result)) {
return result.get(0);
}
throw new UnhandledServerException("No Available Application Run Records.");
return null;
}
}

View File

@ -84,7 +84,7 @@
<table border="0" cellspacing="0" cellpadding="0" role="presentation">
<tbody>
<tr>
<td bgcolor="#11A683" style="border-radius:5px;background-color:#7147E8"><a style="font-size:14px;font-family:poppins,Helvetica,Arial,sans-serif;font-weight:400;line-height:32px;color:#ffffff;text-align:center;text-decoration:none;display:block;background-color:#7147E8;padding:8px 32px;border-radius:5px" href="${viewReportUrl}" title="" target="_blank" data-saferedirecturl="#">View Details</a></td>
<td bgcolor="#11A683" style="border-radius:5px;background-color:#7147E8"><a style="font-size:14px;font-family:poppins,Helvetica,Arial,sans-serif;font-weight:400;line-height:32px;color:#ffffff;text-align:center;text-decoration:none;display:block;background-color:#0950C5;padding:8px 32px;border-radius:5px" href="${viewReportUrl}" title="" target="_blank" data-saferedirecturl="#">View Report</a></td>
</tr>
</tbody>
</table>
@ -104,46 +104,140 @@
</tr>
</tbody>
</table>
<table cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#f8f8f8">
<table cellpadding="" cellspacing="0" border="0" width="100%" bgcolor="#f8f8f8" style="padding: 20px">
<tbody style="padding: 20px">
<tr>
<td style="padding:0px 30px; border-right:1px solid #75757529; border-bottom:1px solid #75757529">
<p style="font-size:14px; color:#757575">Total Data Assets<br><span style="color:rgb(46,53,67);font-family:poppins,Helvetica,Arial,sans-serif;font-size:20px;line-height:150%;font-weight:600;">${totalAssetObj.totalDataAssets}</span><br><span style="font-size:12px; color:#757575">${totalAssetObj.percentChangeMessage} [${totalAssetObj.numberOfDaysChange} Days Change] </span></p>
</td>
<td style="padding: 0px 30px; border-bottom:1px solid #75757529">
<p style="font-size:14px; color:#757575">Data Assets with Description<br><span style="color:rgb(46,53,67);font-family:poppins,Helvetica,Arial,sans-serif;font-size:20px;line-height:150%;font-weight:600;">${descriptionObj.totalAssets}</span><br><span style="font-size:12px; color:#757575"> ${descriptionObj.percentChangeMessage} [${descriptionObj.numberOfDaysChange} Days Change] </span></p>
</td>
</tr>
<tr>
<td style="padding: 0px 30px; border-right:1px solid #75757529">
<p style="font-size:14px; color:#757575">Total Data Assets with Owner<br><span style="color:rgb(46,53,67);font-family:poppins,Helvetica,Arial,sans-serif;font-size:20px;line-height:150%;font-weight:600;">${ownershipObj.totalAssets}</span><br><span style="font-size:12px; color:#757575"> ${ownershipObj.percentChangeMessage} [${ownershipObj.numberOfDaysChange} Days Change] </span></p>
</td>
<td style="padding: 0px 30px">
<p style="font-size:14px; color:#757575">Data Assets with Tiers<br><span style="color:rgb(46,53,67);font-family:poppins,Helvetica,Arial,sans-serif;font-size:20px;line-height:150%;font-weight:600;">${tierObj.totalAssets}</span><br><span style="font-size:12px; color:#757575"> ${tierObj.percentChangeMessage} [${tierObj.numberOfDaysChange} Days Change] </span></p>
</td>
</tr>
</tbody>
</table>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td align="center" valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<td bgcolor="#ffffff" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
</tbody>
</table>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td valign="middle" align="left" bgcolor="#FFFFFF" width="342">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td bgcolor="#ffffff" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
<td width="30"></td>
<td align="left" style="color:rgb(46,53,67);font-family:poppins,Helvetica,Arial,sans-serif;font-size:14px;line-height:150%;font-weight:bold;">
<table cellpadding="0" cellspacing="0" border="0" width="95%">
<tbody>
<tr>
<td align="left" style="color:rgb(46,53,67);font-family:poppins,Helvetica,Arial,sans-serif;font-size:20px;line-height:150%;font-weight:600;"> Total Data Assets</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center">
<td colspan="2" bgcolor="#FFFFFF" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
<tr>
<td width="30"></td>
<td align="left" style="color:#757575;font-family:poppins,Helvetica,Arial,sans-serif;font-size:14px;line-height:150%;font-weight:normal">${totalAssetObj.completeMessage}</td>
</tr>
<tr>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
<tr>
<td width="30"></td>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="font-size:12px; color:#757575"> ${totalAssetObj.percentChangeMessage} [${totalAssetObj.numberOfDaysChange} Days Change]</td>
</tr>
</tbody>
</table>
</td>
<td valign="middle" align="right" bgcolor="#f8f8f8" width="208" height="210">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td align="right" style="color:#292929;font-family:poppins,Helvetica,Arial,sans-serif;font-size:32px;line-height:normal;font-weight:bold">0</td>
</tr>
<tr>
<td align="right" style="color:#757575;font-family:poppins,Helvetica,Arial,sans-serif;font-size:15px;line-height:normal;font-weight:normal">Total Data Assets</td>
</tr>
<tr>
<td valign="bottom" width="160" align="right" style="color:rgb(253,253,253);font-family:poppins,Helvetica,Arial,sans-serif;font-size:15px;line-height:normal;font-weight:normal">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<td align="right" valign="bottom" bgcolor="#f8f8f8" width="100%" height="40">
<table cellspacing="0" cellpadding="0" border="0" align="right">
<tbody>
<tr>
<td valign="middle" align="center" width="400" height="45">
<table cellpadding="0" cellspacing="0" border="0">
<td align="right" valign="bottom">
<table cellpadding="0" cellspacing="0" border="0" align="right">
<tbody>
<tr>
<td bgcolor="#f8f8f8" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#f8f8f8" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
<tr>
<td valign="top" style="color:#292929;font-family:poppins,Helvetica,Arial,sans-serif;font-size:20px;line-height:normal;font-weight:600;text-align: center;">Total Data Assets</td>
</tr>
<tr>
<td colspan="3" style="line-height:18px;font-size:14px; text-align: center; color:#757575">${totalAssetObj.completeMessage}</td>
</tr>
<tr>
<td colspan="3" style="color:#361A8F;font-family:poppins,Helvetica,Arial,sans-serif;font-size:30px;line-height:150%;font-weight:400; text-align: center"><strong>${totalAssetObj.totalDataAssets}</strong></td>
<td width="2"></td>
<#list totalAssetObj.dateMap?keys as key>
<td valign="bottom">
<table cellspacing="0" cellpadding="0" border="0" width="10" align="left">
<tbody>
<tr>
<td valign="bottom" bgcolor="#f8f8f8" height="0" style="line-height:0px;font-size:0px">&nbsp;</td>
</tr>
<tr>
<td valign="bottom" bgcolor="#0950C5" height="${totalAssetObj.dateMap[key]}" style="line-height:${totalAssetObj.dateMap[key]}px;font-size:40px; border-radius: 50px;">&nbsp;</td>
</tr>
</tbody>
</table>
</td>
<td width="30"></td>
</#list>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#757575" height="1" style="line-height:1px;font-size:1px">&nbsp;</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="right" valign="bottom">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td bgcolor="#f8f8f8" height="10" style="line-height:10px;font-size:10px">&nbsp;</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td width="160" align="right" valign="bottom">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td width="5"></td>
<#list totalAssetObj.dateMap?keys as key>
<td valign="bottom" align="right" style="color:#757575;font-family:poppins,Helvetica,Arial,sans-serif;font-size:8px;line-height:150%;font-weight:normal;text-transform:uppercase;letter-spacing:0.3px" aria-label="TotalAssetObjGraph ${key}">${key}</td>
<td width="30"></td>
</#list>
</tr>
</tbody>
</table>
</td>
@ -151,12 +245,11 @@
</tbody>
</table>
</td>
<td width="15"></td>
<td width="15"></td>
</tr>
<tr>
<td bgcolor="#f8f8f8" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#f8f8f8" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
<td colspan="3" bgcolor="#f8f8f8" height="10" style="line-height:10px;font-size:10px">&nbsp;</td>
</tr>
</tbody>
</table>
@ -199,12 +292,16 @@
<tr>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
<#if descriptionObj.kpiAvailable>
<#if descriptionObj.kpiAvailable>
<tr>
<td width="30"></td>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="font-size:12px; color:#757575"><span style="color:#292929; font-weight: 600">Target KPI:</span> ${descriptionObj.targetKpi}% | <span style="color:#292929 ; font-weight: 600">Current KPI:</span> ${descriptionObj.percentCompleted}%</td>
</tr>
</#if>
</#if>
<tr>
<td width="30"></td>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="font-size:12px; color:#757575"> ${descriptionObj.percentChangeMessage} [${descriptionObj.numberOfDaysChange} Days Change]</td>
</tr>
</tbody>
</table>
</td>
@ -337,12 +434,16 @@
<tr>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
<#if ownershipObj.kpiAvailable>
<#if ownershipObj.kpiAvailable>
<tr>
<td width="30"></td>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="font-size:12px; color:#757575"><span style="color:#292929; font-weight: 600">Target KPI:</span> ${ownershipObj.targetKpi}% | <span style="color:#292929 ; font-weight: 600">Current KPI:</span> ${ownershipObj.percentCompleted}%</td>
</tr>
</#if>
<tr>
<td width="30"></td>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="font-size:12px; color:#757575"> ${ownershipObj.percentChangeMessage} [${ownershipObj.numberOfDaysChange} Days Change]</td>
</tr>
</tbody>
</table>
</td>
@ -475,6 +576,10 @@
<tr>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="line-height:20px;font-size:20px">&nbsp;</td>
</tr>
<tr>
<td width="30"></td>
<td colspan="2" bgcolor="#FFFFFF" height="20" style="font-size:12px; color:#757575"> ${tierObj.percentChangeMessage} [${tierObj.numberOfDaysChange} Days Change]</td>
</tr>
</tbody>
</table>
</td>
@ -507,7 +612,7 @@
<#list tierObj.dateMap?keys as key>
<td valign="bottom">
<table cellspacing="0" cellpadding="0" border="0" width="10" align="left">
<tbody>
<tbody>
<tr>
<td valign="bottom" bgcolor="#f8f8f8" height="0" style="line-height:0px;font-size:0px">&nbsp;</td>
</tr>