-
Notifications
You must be signed in to change notification settings - Fork 5
Add Access note to browse by collection page for metadata-only collection #432
Conversation
app/helpers/catalog_helper.rb
Outdated
if accessGroup != nil | ||
|
||
if accessGroup.include?('public') | ||
viewAccess = nil | ||
elsif accessGroup.include?('local') && metadata_colls.include?(document['id']) | ||
viewAccess = 'Restricted View' |
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.
Naming/VariableName: Use snake_case for variable names.
end | ||
meta_colls | ||
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.
Layout/TrailingWhitespace: Trailing whitespace detected.
metadata_only = !collection_response.response['numFound'].zero? | ||
meta_colls << doc['id_t'].to_s if metadata_only | ||
end | ||
meta_colls |
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.
Layout/TrailingWhitespace: Trailing whitespace detected.
other_rights_fquery = "(otherRights_tesim:localDisplay OR otherRights_tesim:metadataDisplay)" | ||
response.docs.each do |doc| | ||
collection_solr_params = { :q => "collections_tesim:#{doc['id'].to_s}", :fq => other_rights_fquery, :rows => 1, :spellcheck => "false" } | ||
collection_response = raw_solr( collection_solr_params ) |
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.
Layout/SpaceInsideParens: Space inside parentheses detected.
response = raw_solr( params ) | ||
other_rights_fquery = "(otherRights_tesim:localDisplay OR otherRights_tesim:metadataDisplay)" | ||
response.docs.each do |doc| | ||
collection_solr_params = { :q => "collections_tesim:#{doc['id'].to_s}", :fq => other_rights_fquery, :rows => 1, :spellcheck => "false" } |
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.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Lint/StringConversionInInterpolation: Redundant use of Object#to_s in interpolation.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
meta_colls = [] | ||
params = {:q => 'visibility_tesim:local', :fq => 'type_tesim:Collection', :spellcheck => "false"} | ||
response = raw_solr( params ) | ||
other_rights_fquery = "(otherRights_tesim:localDisplay OR otherRights_tesim:metadataDisplay)" |
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.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
def metadata_only_collections | ||
meta_colls = [] | ||
params = {:q => 'visibility_tesim:local', :fq => 'type_tesim:Collection', :spellcheck => "false"} | ||
response = raw_solr( params ) |
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.
Layout/SpaceInsideParens: Space inside parentheses detected.
@@ -362,6 +362,20 @@ def collection_search | |||
session[:search] = search | |||
end | |||
|
|||
def metadata_only_collections | |||
meta_colls = [] | |||
params = {:q => 'visibility_tesim:local', :fq => 'type_tesim:Collection', :spellcheck => "false"} |
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.
Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
app/helpers/catalog_helper.rb
Outdated
viewAccess = nil | ||
elsif accessGroup.include?('local') | ||
elsif access_group.include?('local') && metadata_colls.include?(document['id']) | ||
viewAccess = 'Restricted View' |
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.
Naming/VariableName: Use snake_case for variable names.
app/helpers/catalog_helper.rb
Outdated
if accessGroup != nil | ||
|
||
if accessGroup.include?('public') | ||
if access_group.include?('public') |
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.
Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison.
app/helpers/catalog_helper.rb
Outdated
viewAccess = nil | ||
if access_group != 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.
Style/NonNilCheck: Prefer !expression.nil? over expression != nil.
1686261
to
a0e9e46
Compare
app/helpers/catalog_helper.rb
Outdated
def display_access_control_level(document, metadata_colls) | ||
access_group = document['read_access_group_ssim'] # "public" > "local" > "dams-curator" == "dams-rci" == default | ||
view_access = nil | ||
if !access_group.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.
Style/NegatedIf: Favor unless over if for negative conditions.
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.
+1, I think this could be if access_group
, or simply an early return if it is nil.
@ucsdlib/developers - please review |
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.
Overall, LGTM 👍
A couple questions, but the implementation looks good. I am curious how much these queries will slow things down over time, hopefully not too much and not much we can do about it at this point anyway :)
app/helpers/catalog_helper.rb
Outdated
viewAccess = 'Restricted to UC San Diego use only' | ||
def display_access_control_level(document, metadata_colls) | ||
access_group = document['read_access_group_ssim'] # "public" > "local" > "dams-curator" == "dams-rci" == default | ||
view_access = 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.
It looks like the fallback value here, from the else
condition, is Curator Only
. If that's true, could you possibly set the initial value of view_access
to that instead of nil
? Then you could drop the else
entirely.
Somewhat related I'm curious why we use nil
instead of just ''
for public
, but if it's working then I suppose it's not work messing with ;)
app/helpers/catalog_helper.rb
Outdated
def display_access_control_level(document, metadata_colls) | ||
access_group = document['read_access_group_ssim'] # "public" > "local" > "dams-curator" == "dams-rci" == default | ||
view_access = nil | ||
if !access_group.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.
+1, I think this could be if access_group
, or simply an early return if it is nil.
.rubocop.yml
Outdated
Style/Next: | ||
Enabled: true | ||
|
||
Style/NegatedIf: | ||
Exclude: | ||
- 'app/helpers/*' |
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.
If the negated condition noted by Hound is dropped (turned into an else or early return/guard clause) will this still be needed?
@mcritchlow - I updated the code and removed the negated condition from rubocop like you suggested and Hound didn't complain. The circleci build is still running. Thanks |
…ion page Fix hound violations Fix hound violation Fix hound violation Fix hound issue Update rubocop Fix access control failed tests
46f3e68
to
541ab00
Compare
@mcritchlow - The code has been updated and the tests passed. Could you review them again? Thanks |
LGTM 👍 |
👍 |
Fixes #409 ; refs #409
Display the access note for metadata-only view collections.
@ucsdlib/developers - please review