Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Add Access note to browse by collection page for metadata-only collection #432

Merged
merged 1 commit into from
Apr 26, 2018

Conversation

VivianChu
Copy link
Member

Fixes #409 ; refs #409

Display the access note for metadata-only view collections.

@ucsdlib/developers - please review

if accessGroup != nil

if accessGroup.include?('public')
viewAccess = nil
elsif accessGroup.include?('local') && metadata_colls.include?(document['id'])
viewAccess = 'Restricted View'

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

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

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 )

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" }

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)"

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 )

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"}

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.

viewAccess = nil
elsif accessGroup.include?('local')
elsif access_group.include?('local') && metadata_colls.include?(document['id'])
viewAccess = 'Restricted View'

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.

if accessGroup != nil

if accessGroup.include?('public')
if access_group.include?('public')

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.

viewAccess = nil
if access_group != nil

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.

@VivianChu VivianChu force-pushed the feature/browse_collection_metadataonly branch from 1686261 to a0e9e46 Compare April 11, 2018 23:53
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?

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.

Copy link
Member

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.

@coveralls
Copy link

coveralls commented Apr 12, 2018

Coverage Status

Coverage increased (+0.2%) to 66.242% when pulling 541ab00 on feature/browse_collection_metadataonly into 84da581 on develop.

@VivianChu
Copy link
Member Author

@ucsdlib/developers - please review

Copy link
Member

@mcritchlow mcritchlow left a 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 :)

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
Copy link
Member

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 ;)

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?
Copy link
Member

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/*'
Copy link
Member

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?

@VivianChu
Copy link
Member Author

VivianChu commented Apr 26, 2018

@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
@VivianChu VivianChu force-pushed the feature/browse_collection_metadataonly branch from 46f3e68 to 541ab00 Compare April 26, 2018 21:18
@VivianChu
Copy link
Member Author

@mcritchlow - The code has been updated and the tests passed. Could you review them again? Thanks

@mcritchlow
Copy link
Member

LGTM 👍

@hweng
Copy link
Contributor

hweng commented Apr 26, 2018

👍

@hweng hweng merged commit 5438dca into develop Apr 26, 2018
@hweng hweng deleted the feature/browse_collection_metadataonly branch April 26, 2018 22:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants