From 7cfc4c44cf4fa7015783f4d4251c42ff6b9e82f5 Mon Sep 17 00:00:00 2001 From: Jiaqi Liu <2257440489@qq.com> Date: Tue, 20 Mar 2018 12:06:12 -0700 Subject: [PATCH 1/2] Fix 'descriptionription' mis-naming in dimension field --- .../dimension/impl/KeyValueStoreDimension.java | 2 +- .../web/endpoints/DimensionsServlet.java | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/data/dimension/impl/KeyValueStoreDimension.java b/fili-core/src/main/java/com/yahoo/bard/webservice/data/dimension/impl/KeyValueStoreDimension.java index 2dcfc4a562..90603e3c1d 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/data/dimension/impl/KeyValueStoreDimension.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/data/dimension/impl/KeyValueStoreDimension.java @@ -564,7 +564,7 @@ public DimensionField getKey() { @Override public DimensionRow parseDimensionRow(Map fieldNameValueMap) { - // This rewrite need to be removed once description is normalized in legacy implementations + // TODO: This rewrite need to be removed once description is normalized in legacy implementations String desc = fieldNameValueMap.remove("description"); if (desc != null) { fieldNameValueMap.put("desc", desc); diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/web/endpoints/DimensionsServlet.java b/fili-core/src/main/java/com/yahoo/bard/webservice/web/endpoints/DimensionsServlet.java index 702c948eb2..1c080455da 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/web/endpoints/DimensionsServlet.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/web/endpoints/DimensionsServlet.java @@ -311,7 +311,7 @@ public Response getDimensionRows( .map(stream -> stream.collect( StreamUtils.toLinkedMap( - entry -> entry.getKey().getName().replace("desc", "description"), + entry -> getDescriptionKey(entry.getKey().getName()), Map.Entry::getValue ) ) @@ -479,4 +479,19 @@ public static String getDimensionValuesUrl(Dimension dimension, final UriInfo ur .build(dimension.getApiName()) .toASCIIString(); } + + /** + * If a description dimension fields has a name of "desc", transforms it to "description", otherwise returns the + * original without modification. + *

+ * TODO: This rewrite need to be removed once description is normalized in legacy implementations, see + * {@link com.yahoo.bard.webservice.data.dimension.impl.KeyValueStoreDimension#parseDimensionRow(Map)}. + * + * @param fieldName The name of the description field name + * + * @return a description dimension field with name "description" + */ + private static String getDescriptionKey(String fieldName) { + return fieldName.contains("description") ? fieldName : fieldName.replace("desc", "description"); + } } From d8b1fcfeec7f771dc08c026f67c491b201cf80bd Mon Sep 17 00:00:00 2001 From: Jiaqi Liu <2257440489@qq.com> Date: Tue, 20 Mar 2018 12:11:41 -0700 Subject: [PATCH 2/2] Add change log & update doc --- CHANGELOG.md | 5 +++++ docs/end-user-api.md | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4efcf2316..55bf0a8d55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -266,6 +266,11 @@ Current ### Fixed: +- [Fix 'descriptionription' mis-naming in dimension field](https://github.com/yahoo/fili/pull/655) + * This is caused by a "desc" -> "description" string replacement. A string handling method has been added to + detect "desc" and transform it to "description". If it already comes with "description", no string transformation + is made + - [Fix caching condition](https://github.com/yahoo/fili/pull/647) * We want to cache partial or volatile data when `cache_partial_data` is set to true. This is condition is currently reversed. This PR shall fix it diff --git a/docs/end-user-api.md b/docs/end-user-api.md index c6c42ed234..3f4f2ece6d 100644 --- a/docs/end-user-api.md +++ b/docs/end-user-api.md @@ -58,9 +58,9 @@ aggregating, as well as filtering of data, and are a critical part of the system fields, as well as a collection of possible values for that dimension. These dimension fields and values serve two primary purposes: Filtering and Annotating data query results. -All dimensions have an Id property (a natural key) and a Desc property (a human-readable description). Both of these -fields can be used to filter rows reported on, and both of these fields are included in the data query result set for -each dimension. +All dimensions have an Id property (a natural key) and a Description property (a human-readable description). Both of +these fields can be used to filter rows reported on, and both of these fields are included in the data query result set +for each dimension. Get a [list of all dimensions](https://sampleapp.fili.org/v1/dimensions):