-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactor Solr query class & add SolrMultiQuery class to handle gett…
…ing multiple objects from a set of URIs (as in the case of related items). This avoids performance problems by submitting only a single query to Solr regardless of the number of related items an object has. - Add some basic versions of a few objects we haven't come across yet which are cropping up as related item object types - Update related items partial to match wireframes & include data from related items Solr query
- Loading branch information
Showing
15 changed files
with
176 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CommandPaper < ContentObject | ||
|
||
def initialize(content_object_data) | ||
super | ||
end | ||
|
||
def template | ||
'search/objects/command_paper' | ||
end | ||
|
||
def object_name | ||
'command paper' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class CommitteeProceeding < ContentObject | ||
|
||
def initialize(content_object_data) | ||
super | ||
end | ||
|
||
def template | ||
'search/objects/committee_proceeding' | ||
end | ||
|
||
def object_name | ||
'committee proceeding' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class EuropeanDepositedDocument < ContentObject | ||
|
||
def initialize(content_object_data) | ||
super | ||
end | ||
|
||
def template | ||
'search/objects/european_deposited_document' | ||
end | ||
|
||
def object_name | ||
'european deposited document' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class EuropeanMaterial < ContentObject | ||
|
||
def initialize(content_object_data) | ||
super | ||
end | ||
|
||
def template | ||
'search/objects/european_material' | ||
end | ||
|
||
def object_name | ||
'european material' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class HouseOfCommonsPaper < ContentObject | ||
|
||
def initialize(content_object_data) | ||
super | ||
end | ||
|
||
def template | ||
'search/objects/house_of_commons_paper' | ||
end | ||
|
||
def object_name | ||
'house of commons paper' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class ResearchMaterial < ContentObject | ||
|
||
def initialize(content_object_data) | ||
super | ||
end | ||
|
||
def template | ||
'search/objects/research_material' | ||
end | ||
|
||
def object_name | ||
'research material' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class SolrMultiQuery < ApiCall | ||
# for fetching related item data etc. | ||
|
||
require 'open-uri' | ||
require 'net/http' | ||
|
||
attr_reader :object_uris | ||
|
||
BASE_API_URI = "https://api.parliament.uk/new-solr/" | ||
|
||
def initialize(params) | ||
@object_uris = params[:object_uris] | ||
end | ||
|
||
def object_data | ||
return evaluated_response if evaluated_response['statusCode'] == 500 | ||
|
||
evaluated_response['response']['docs'] | ||
end | ||
|
||
def ruby_uri | ||
# this constructs q=uri: "www.google.com" OR uri: "www.apple.com" OR ... | ||
|
||
uri = build_uri("#{BASE_API_URI}select?q=#{search_string}&rows=50") | ||
|
||
# TODO: this currently returns the first 50 results; this should be set to a sensible number? | ||
end | ||
|
||
def search_string | ||
query = object_uris.join("%22 OR uri:%22") | ||
"(uri:%22#{query}%22)" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
<div class="about-item"> | ||
<h3 class="content-heading" id="related-items">Related items</h3> | ||
|
||
<!-- relation_t or relation_uri--> | ||
<!--we can only provide further information where there's a uri to follow--> | ||
<!-- however it's further complicated by relation_t containing uris--> | ||
<!-- if we have the uri, we can also add date_dt, type_ses and legislature_ses--> | ||
|
||
<% related_items.each do |related_item| %> | ||
<div> | ||
<%= link_to related_item, '/' %><br/> | ||
</div> | ||
<div> | ||
<%= link_to related_item.page_title, related_item.content_object_data['uri'] %><br/> | ||
<% if related_item.date %> | ||
<%= related_item.date&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %> | ||
<% end %> | ||
<% if related_item.type %> | ||
<%= ses_name(related_item.type) %><br/> | ||
<% end %> | ||
<% if related_item.legislature %> | ||
<%= ses_name(related_item.legislature) %><br/> | ||
<% end %> | ||
</div> | ||
<br/> | ||
<% end %> | ||
</div> |