Skip to content

Commit

Permalink
feat(analytics): display glossary term percentage coverage (datahub-p…
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Radhakrishnan authored and maggiehays committed Aug 1, 2022
1 parent 937b18c commit 104de7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,29 @@ private Optional<Highlight> getEntityMetadataStats(String title, EntityType enti
}
int numEntitiesWithOwners = getNumEntitiesFiltered(index, ImmutableMap.of("hasOwners", ImmutableList.of("true")));
int numEntitiesWithTags = getNumEntitiesFiltered(index, ImmutableMap.of("hasTags", ImmutableList.of("true")));
int numEntitiesWithGlossaryTerms =
getNumEntitiesFiltered(index, ImmutableMap.of("hasGlossaryTerms", ImmutableList.of("true")));
int numEntitiesWithDescription =
getNumEntitiesFiltered(index, ImmutableMap.of("hasDescription", ImmutableList.of("true")));

String bodyText = "";
if (numEntities > 0) {
double percentWithOwners = 100.0 * numEntitiesWithOwners / numEntities;
double percentWithTags = 100.0 * numEntitiesWithTags / numEntities;
double percentWithGlossaryTerms = 100.0 * numEntitiesWithGlossaryTerms / numEntities;
double percentWithDescription = 100.0 * numEntitiesWithDescription / numEntities;
if (entityType == EntityType.DOMAIN) {
// Don't show percent with domain when asking for stats regarding domains
bodyText = String.format("%.2f%% have owners, %.2f%% have tags, %.2f%% have description!", percentWithOwners,
percentWithTags, percentWithDescription);
bodyText =
String.format("%.2f%% have owners, %.2f%% have tags, %.2f%% have glossary terms, %.2f%% have description!",
percentWithOwners, percentWithTags, percentWithGlossaryTerms, percentWithDescription);
} else {
int numEntitiesWithDomains =
getNumEntitiesFiltered(index, ImmutableMap.of("hasDomain", ImmutableList.of("true")));
double percentWithDomains = 100.0 * numEntitiesWithDomains / numEntities;
bodyText =
String.format("%.2f%% have owners, %.2f%% have tags, %.2f%% have description, %.2f%% have domain assigned!",
percentWithOwners, percentWithTags, percentWithDescription, percentWithDomains);
bodyText = String.format(
"%.2f%% have owners, %.2f%% have tags, %.2f%% have glossary terms, %.2f%% have description, %.2f%% have domain assigned!",
percentWithOwners, percentWithTags, percentWithGlossaryTerms, percentWithDescription, percentWithDomains);
}
}
return Optional.of(Highlight.builder().setTitle(title).setValue(numEntities).setBody(bodyText).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ record GlossaryTermAssociation {
@Searchable = {
"fieldName": "glossaryTerms",
"fieldType": "URN",
"hasValuesFieldName": "hasGlossaryTerms",
"addToFilters": true,
"filterNameOverride": "Glossary Term"
}
Expand Down

0 comments on commit 104de7d

Please sign in to comment.