Skip to content

Commit a81e14d

Browse files
authored
Merge branch 'datahub-project:master' into master
2 parents e1d1d1b + 2615e07 commit a81e14d

File tree

22 files changed

+1135
-318
lines changed

22 files changed

+1135
-318
lines changed

Diff for: datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/entitytype/EntityTypeUrnMapper.java

+4
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,8 @@ public static String getEntityTypeUrn(String name) {
111111
}
112112
return ENTITY_NAME_TO_ENTITY_TYPE_URN.get(name);
113113
}
114+
115+
public static boolean isValidEntityType(String entityTypeUrn) {
116+
return ENTITY_TYPE_URN_TO_NAME.containsKey(entityTypeUrn);
117+
}
114118
}

Diff for: datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/structuredproperty/StructuredPropertyMapper.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.linkedin.datahub.graphql.generated.StructuredPropertySettings;
2121
import com.linkedin.datahub.graphql.generated.TypeQualifier;
2222
import com.linkedin.datahub.graphql.types.common.mappers.util.MappingHelper;
23+
import com.linkedin.datahub.graphql.types.entitytype.EntityTypeUrnMapper;
2324
import com.linkedin.datahub.graphql.types.mappers.MapperUtils;
2425
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
2526
import com.linkedin.entity.EntityResponse;
@@ -30,7 +31,9 @@
3031
import java.util.stream.Collectors;
3132
import javax.annotation.Nonnull;
3233
import javax.annotation.Nullable;
34+
import lombok.extern.slf4j.Slf4j;
3335

36+
@Slf4j
3437
public class StructuredPropertyMapper
3538
implements ModelMapper<EntityResponse, StructuredPropertyEntity> {
3639

@@ -141,8 +144,21 @@ private TypeQualifier mapTypeQualifier(final StringArrayMap gmsTypeQualifier) {
141144
final TypeQualifier typeQualifier = new TypeQualifier();
142145
List<String> allowedTypes = gmsTypeQualifier.get(ALLOWED_TYPES);
143146
if (allowedTypes != null) {
147+
// filter out correct allowedTypes
148+
List<String> validAllowedTypes =
149+
allowedTypes.stream()
150+
.filter(EntityTypeUrnMapper::isValidEntityType)
151+
.collect(Collectors.toList());
152+
if (validAllowedTypes.size() != allowedTypes.size()) {
153+
log.error(
154+
String.format(
155+
"Property has invalid allowed types set. Current list of allowed types: %s",
156+
allowedTypes));
157+
}
144158
typeQualifier.setAllowedTypes(
145-
allowedTypes.stream().map(this::createEntityTypeEntity).collect(Collectors.toList()));
159+
validAllowedTypes.stream()
160+
.map(this::createEntityTypeEntity)
161+
.collect(Collectors.toList()));
146162
}
147163
return typeQualifier;
148164
}

Diff for: datahub-web-react/src/app/analyticsDashboard/components/TimeSeriesChart.tsx

+34-3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,38 @@ export function computeLines(chartData: TimeSeriesChartType, insertBlankPoints:
8484
return returnLines;
8585
}
8686

87+
const formatAxisDate = (value: number, chartData: TimeSeriesChartType) => {
88+
const date = new Date(value);
89+
90+
switch (chartData.interval) {
91+
case 'MONTH':
92+
return date.toLocaleDateString('en-US', {
93+
month: 'short',
94+
year: 'numeric',
95+
timeZone: 'UTC',
96+
});
97+
case 'WEEK':
98+
return date.toLocaleDateString('en-US', {
99+
month: 'short',
100+
day: 'numeric',
101+
timeZone: 'UTC',
102+
});
103+
case 'DAY':
104+
return date.toLocaleDateString('en-US', {
105+
weekday: 'short',
106+
day: 'numeric',
107+
timeZone: 'UTC',
108+
});
109+
default:
110+
return date.toLocaleDateString('en-US', {
111+
month: 'short',
112+
day: 'numeric',
113+
year: 'numeric',
114+
timeZone: 'UTC',
115+
});
116+
}
117+
};
118+
87119
export const TimeSeriesChart = ({
88120
chartData,
89121
width,
@@ -117,6 +149,7 @@ export const TimeSeriesChart = ({
117149
strokeWidth={style?.axisWidth}
118150
tickLabelProps={{ fill: 'black', fontFamily: 'inherit', fontSize: 10 }}
119151
numTicks={3}
152+
tickFormat={(value) => formatAxisDate(value, chartData)}
120153
/>
121154
<Axis
122155
orientation="right"
@@ -151,9 +184,7 @@ export const TimeSeriesChart = ({
151184
tooltipData?.nearestDatum && (
152185
<div>
153186
<div>
154-
{new Date(
155-
Number(accessors.xAccessor(tooltipData.nearestDatum.datum)),
156-
).toDateString()}
187+
{formatAxisDate(accessors.xAccessor(tooltipData.nearestDatum.datum), chartData)}
157188
</div>
158189
<div>{accessors.yAccessor(tooltipData.nearestDatum.datum)}</div>
159190
</div>

0 commit comments

Comments
 (0)