mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 10:39:30 +00:00 
			
		
		
		
	Add a Workaround for the Tier Calculation on DataInsightsReport (#17555)
This commit is contained in:
		
							parent
							
								
									336b14231f
								
							
						
					
					
						commit
						d0c08fb6e6
					
				| @ -345,7 +345,7 @@ public class DataInsightsReportApp extends AbstractNativeApplication { | |||||||
|     // Get total Assets Data |     // Get total Assets Data | ||||||
|     // This assumes that on a particular date the correct count per entities are given |     // This assumes that on a particular date the correct count per entities are given | ||||||
|     Map<String, Double> dateWithCount = |     Map<String, Double> dateWithCount = | ||||||
|         getDateMapWithCountFromChart( |         getDateMapWithCountFromTierChart( | ||||||
|             "total_data_assets_by_tier", timeConfig.startTime(), timeConfig.endTime(), team); |             "total_data_assets_by_tier", timeConfig.startTime(), timeConfig.endTime(), team); | ||||||
| 
 | 
 | ||||||
|     Double previousHasTier = dateWithCount.getOrDefault(timeConfig.startDay(), 0D); |     Double previousHasTier = dateWithCount.getOrDefault(timeConfig.startDay(), 0D); | ||||||
| @ -388,6 +388,38 @@ public class DataInsightsReportApp extends AbstractNativeApplication { | |||||||
|         dateMap); |         dateMap); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   // Hack: Because on Data Insights when a Tier is not present is set as 'NoTier', this calculation | ||||||
|  |   // will return 100% of the entities | ||||||
|  |   // with Tier. | ||||||
|  |   // This should be fixed by using the .missing() attribute for ElasticSearch aggregations and | ||||||
|  |   // should be planned for 1.6. | ||||||
|  |   // Meanwhile this is a workaround. | ||||||
|  |   private Map<String, Double> getDateMapWithCountFromTierChart( | ||||||
|  |       String chartName, Long startTime, Long endTime, String team) throws IOException { | ||||||
|  |     String filter = prepareTeamFilter(team); | ||||||
|  |     Map<String, DataInsightCustomChartResultList> systemChartMap = | ||||||
|  |         systemChartRepository.listChartData(chartName, startTime, endTime, filter); | ||||||
|  |     return systemChartMap.get(chartName).getResults().stream() | ||||||
|  |         .filter( | ||||||
|  |             result -> | ||||||
|  |                 !result | ||||||
|  |                     .getGroup() | ||||||
|  |                     .equals( | ||||||
|  |                         "NoTier")) // Workaround to remove Assets without Tiers from the equation | ||||||
|  |         .map( | ||||||
|  |             result -> { | ||||||
|  |               Map<String, Double> dayCount = new HashMap<>(); | ||||||
|  |               dayCount.put( | ||||||
|  |                   TimestampUtils.timestampToString(result.getDay().longValue(), "dd"), | ||||||
|  |                   result.getCount()); | ||||||
|  |               return dayCount; | ||||||
|  |             }) | ||||||
|  |         .flatMap(map -> map.entrySet().stream()) | ||||||
|  |         .collect( | ||||||
|  |             Collectors.groupingBy( | ||||||
|  |                 Map.Entry::getKey, Collectors.summingDouble(Map.Entry::getValue))); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   private Map<String, Double> getDateMapWithCountFromChart( |   private Map<String, Double> getDateMapWithCountFromChart( | ||||||
|       String chartName, Long startTime, Long endTime, String team) throws IOException { |       String chartName, Long startTime, Long endTime, String team) throws IOException { | ||||||
|     String filter = prepareTeamFilter(team); |     String filter = prepareTeamFilter(team); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 IceS2
						IceS2