-
Notifications
You must be signed in to change notification settings - Fork 7
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
Use facets for metadata #148
Conversation
@@ -64,8 +76,7 @@ def related | |||
|
|||
def results | |||
@results ||= ResultSet.get( | |||
slug, | |||
document_type, | |||
self, |
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'm really unsure about this. It makes the owning object unclear.
My gut says to start by removing calls to the some_finder_presenter.results
method here with direct uses of ResultSet
, but I'm not entirely sure.
7357fd9
to
a743bae
Compare
Hold off merging this while I do some investigation. Think I've found a small issue with DSU. |
917d9ec
to
4ca0b5e
Compare
This is good to go now. I noticed some weirdness with the metadata labels not being changed to |
First pass at a doc for what the Finder Content Item should contain. Leaving the facets for now until #148 is merged.
description = description.gsub(/\.\s[A-Z].*/, '.') if description.present? && finder.show_summaries? | ||
end | ||
|
||
def date_metadata_keys |
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 think all these metadata key and mapping methods can be private
Review still in progress! TBC |
4ca0b5e
to
5952134
Compare
|
||
# This truncates the description at the end of the first sentence | ||
description = description.gsub(/\.\s[A-Z].*/, '.') if description.present? && finder.show_summaries? | ||
end |
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.
What about something like this to break it down a bit?
def summary
if finder.show_summaries? && description.present?
description.gsub(/\.\s[A-Z].*/, '.')
end
end
private # or in the initializer
def description
attrs.fetch(:description, nil)
end
e61d488
to
00ce854
Compare
04506c1
to
8778e01
Compare
|
||
def initialize(attrs) | ||
def initialize(attrs, finder) | ||
attrs = attrs.with_indifferent_access |
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.
What prompted the change to turn this into a HashWithIndifferentAccess
?
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.
All the test data is JSON, but the hash returned in the real world is symbols so all these setters in the initialize method fail in the tests. Should I change all the data?
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.
We should make the test data reflect the real world data – otherwise someone could remove this line and replace all the fetch
arguments with strings, and the tests would indicate everything is fine
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.
For reference for anyone else this was discussed offline. This line was originally in https://github.com/alphagov/finder-frontend/blob/master/app/parsers/document_parser.rb#L3 but because we don't have a DocumentParser
anymore I moved this line to the initialize method of Document
.
Sorry for adding another round of comments. This really is good work. I'll come over and work with you to get it merged today. |
This commit removes the document models which defined what attrs to be returned as metadata and if a summary should be shown.
As we no longer need to parse documents, we can remove this file and it's spec.
We can now use the facets to generate the metadata apart from certain metadata keys which not have a corresponding filter so we need to introduce a distinction. This commit does a fair bit of refactoring around this as well as introducing a `filterable?` method to the existing facet types. I've also exposed methods for `Finder#filters` and `Finder#metadata` to access these more easily. I've also replace the existing Facet class with one which is unfilterable and all the other facets are subclasses from FilterableFacet which subclasses from Facet itself.
This commit alows us to see if the Finder should show summaries.
Now that we don't need this Abstract class we can rename it to Document. This commit also refactors it to recieve the Finder which it uses to see if it should have a summary along with the facets which are used to do metadata value to label conversion.
As we use the Finder and it's Facets we need to pass it down through to the Document. This commit updates the ResultSet model, the ResultSetParser and the latter's spec.
This class still exists so we can set the values, but now we can define filterable using the facet attrs set in the schema.
This commit updates the FacetParser to handle unfilterable facets properly and updates it's spec.
With the new facet structure, we can use this to figure out what are dates and what are text based metadata.
This commit adds the short_names to the facets in the CMA Case Finder fixture along with the closed date facet.
This new method is a bit cleaner than what was there previously.
This new method removes an unnecessary method and moves the short_name call to the Finder.
8778e01
to
17fd23d
Compare
🎆 |
🎉🎉 |
This PR contains the work necessary to reduce specificity in FinderFrontend. To do this we need to remove each Document's Model and use the Finder to figure out what fields we are asking to be returned from Rummager and what metadata values should we show for each document. The way I've done this is adding the concept of a
FilterableFacet
and changingFacet
to represent information about a set of metadata key/value pairs and if this should be filterable we then suggest a type of{multi-select|date}
and it becomes aFilterableFacet
.The commits roughly go as follows:
Facet
andFilterableFacet
and exposeFinder#metadata
andFinder#filters
AbstractDocument
toDocument
and use the facets to convert metadata values to labelsFinderPresenter
object down to theDocument
closed_date
facetAfter some discussion with @evilstreak I took a bit of a different approach and added extra commits which do the following:
Facet
class or one of it's child classes.FacetParser
now uses this new way of initialising the Facets.The additional commits were made to handle edge cases in: