-
Notifications
You must be signed in to change notification settings - Fork 80
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
serializers: inject ui config in aggregation buckets #213
Conversation
if bucket.get("subtype"): | ||
bucket["subtype"]["buckets"] = list(map( | ||
partial(self._set_bucket_label, labels_map), | ||
bucket["subtype"]["buckets"])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: This logic is repeated a few times. Can it be made a helper function?
return dict( | ||
access_right=dict( | ||
category=obj["access"]["access_right"] | ||
)) | ||
|
||
def _serialize_ui_options_from_vocabulary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function works for the currently present Vocabularies but maybe it's worth considering a recursive approach if we expect depth>2 in any future ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @lnielsen
bucket_label = labels_map.get(bucket["key"]) | ||
if bucket_label: | ||
bucket["label"] = bucket_label | ||
if bucket.get("subtype"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moderate: subtype
is a specific key for this vocabulary, I think we need a more general approach. I think we can safely assume in this case that any extra key corresponds to a sub-bucket key, but we could also check the existence of the buckets
key in the nested object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked Zenodo and it seems we use the subtype
key for child aggregations. Of course, we should force this in our UI configuration. I assumed that we can normalize the interface by having all nested aggregations under subtype
field. If not, then it needs some more dynamic checking but not sure if it's worth it... @lnielsen WDYT?
895ac66
to
dd2e250
Compare
""" | ||
bucket_label = labels_map.get(bucket["key"]) | ||
if bucket_label: | ||
bucket["label"] = bucket_label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: We should add the doc_count
to the label
here to keep the same visuals.
ecb2c75
to
d40eeb4
Compare
partial(self._set_bucket_label, label_map), | ||
buckets)) | ||
|
||
def _serialize_resource_type_agg(self, resource_type_agg): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: These functions could probably be merged in a generic one using only a key
and the top bucket.
48cf275
to
c169e48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
c169e48
to
fb4c46b
Compare
fb4c46b
to
166b584
Compare
No description provided.