Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'descriptionription' mis-naming in dimension field #655

Merged
merged 2 commits into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/end-user-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public DimensionField getKey() {

@Override
public DimensionRow parseDimensionRow(Map<String, String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
Expand Down Expand Up @@ -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.
* <p>
* 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");
}
}