-
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
IPO trademark decisions finder #2923
Conversation
53eb8b4
to
7fd2e6a
Compare
263dcb2
to
e466a4c
Compare
0a11ae4
to
ec3b023
Compare
dcaaede
to
adfb209
Compare
f0059cd
to
34e5917
Compare
5af63d3
to
35d0043
Compare
d3df0a6
to
e679a78
Compare
833a217
to
8f60fd6
Compare
56791ed
to
ed1383c
Compare
ddeb768
to
ec77e96
Compare
ec77e96
to
41925aa
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.
Good stuff, couple of minor suggestions but nothing that should stop merging if you're wanting to 🚢
Edit: well, except the failing example 😅
return unless @document | ||
|
||
@document.finder_schema.nested_facets.pluck("key", "sub_facet_key").each do |facet_key, sub_facet_key| | ||
next unless @document.send(sub_facet_key) |
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.
Would respond_to?
be more semantically appropriate here?
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.
unfortunately no, because respond_to? would return true, but the actual value of it may be blank or nil
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.
alternatively, i've been changing the public_send
s to assign_attributes
so i'm sure we can change it to get_attribute
of some sort
assign_attributes(clean_key(nested_facet_from_schema["key"]) => parent_facet_value.uniq) if parent_facet_value.any? | ||
assign_attributes(clean_key(nested_facet_from_schema["sub_facet_key"]) => nested_facet_value.uniq) if nested_facet_value.any? | ||
end | ||
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.
I think at this point it's probably worth creating a facet model to abstract some of this away from the document like we did for email alerts, but we can maybe pair on that in a separate PR if anyone is interested? Might also save us from all the merging in the controller, not sure about that though
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.
sounds good! yes, maybe we can do that as a separate thing
expect(SecureRandom).to receive(:uuid).and_return(stub_content_id) | ||
end | ||
|
||
it "should create a document and send draft to Publishing API" do |
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.
Bit worrying that this test was missing!
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 do cover this in feature tests too, but it's handy to have a controller test, closer to the code.
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.
Maybe it makes sense for the feature tests to stay more UI-focused, and bring the publishing API expectations in controller tests.
], | ||
}, | ||
"save" => "", | ||
"document_type_slug" => "trademark-decisions", |
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 wonder if we should create ourselves a test specialist finder that never gets published. Would be nice not to have to use actual finders in our generic tests.
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 like this, for the next person 😅
@@ -0,0 +1,31 @@ | |||
class DocumentMetadataComponent < ViewComponent::Base |
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 like that this is a view component now 🙌
41925aa
to
81ce561
Compare
Bumps [govuk_sidekiq](https://github.com/alphagov/govuk_sidekiq) from 9.0.5 to 9.0.6. - [Changelog](https://github.com/alphagov/govuk_sidekiq/blob/main/CHANGELOG.md) - [Commits](alphagov/govuk_sidekiq@v9.0.5...v9.0.6) --- updated-dependencies: - dependency-name: govuk_sidekiq dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.180.0 to 1.181.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) --- updated-dependencies: - dependency-name: aws-sdk-s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.18.2 to 1.18.3. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/v1.18.3/CHANGELOG.md) - [Commits](sparklemotion/nokogiri@v1.18.2...v1.18.3) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.181.0 to 1.182.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) --- updated-dependencies: - dependency-name: aws-sdk-s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
… finder schema Options_for returns a tuple of strings to populate select dropdowns which feels like view logic rather than model logic. Moving this out and exposing allowed values on the facet instead.
Add a helper method to render nested facets. In the schema, the parent facet now has a `sub_facets` field containing facet-like objects with `label` and `value` fields. We implemented a single dropdown that merges the facets' values (main facet and sub facets, essentially leaf nodes). The user sees dasherised labels in the format 'Parent label - child label'. Moved to using generic specialist form views for trademark decision view. The nested facet options method works for both cases whether or not the facet value has sub-facets or not, so it should be safe to use by default. Remove options_for and replace with select_options_for_facet
When we send the document to Publishing API, we write logic into the document model to figure out whether the leaf node is a parent facet or sub-facet value in the dropdown, and split the metadata we send to Publishing API into its own facet and a separate sub-facet. The reasoning behind this is that if we send them as separate facets, we can keep Publishing API and Search API functionality unchanged..
When we load the edit page or new page again, the document is loaded from Publishing API, with the facet and sub-facet being separate facets, but the dropdown element expects a combined leaf node dropdown, so we have to merge them back together again into the main facet field. We need to collate the values for the `ipo_grounds_section` and `ipo_grounds_sub_section` fields in the one field we do render (`ipo_grounds_section`).
…a summary Additional lookup is required to find the correct label for a given key, when the facet is nested.
Since this facet has over 150 options, we're configuring it to be searchable.
81ce561
to
ab6c332
Compare
This PR implements a new feature - nested facets - and uses the IPO trademark decision finder's config to test the implementation. The current version includes all finder requirements, and is ready to be released as draft, alongside its other PRs: publishing-api and search-api.
At the core of the implementation is the decision to tag a document with both facet and subfacet, in order to minimise the changes required in publishing-api and search-api. Details can be found in the associated ADR. The tagging has been tested in integration, including that search-api returns the correct tags. This query returns the subfacet, as expected:
Upcoming work will address Finder Frontend filtering.
We're also using a feature that is not very commonly used, found elsewhere on this finder - to help search long lists of facet options. This will be used in other upcoming finders, and we've proven that it works successfully here (required setting
show_option_select_filter
in specialist publisher, and the field type assearchable_multivalued_text
in search api).Specialist Publisher Trademark Decisions view:
Formed filled out:
!Note: we only allow selecting a child if the parent has any children. Whilst this is not the case for this finder config, if a nested facet value did not have any children, the parent value would appear as a select option.
Summary page:
Document preview
!Note: This is quite verbose on the nested values - we will discuss a different approach.
Finder summary
Finder
Finder Date filter

Searchable filter
Free text search
Nested facets filter
!Note: nested facets are not currently rendering on the Front End, so we're only rendering parent options
Trello nested facets
Trello IPO finder