-
Notifications
You must be signed in to change notification settings - Fork 5
Fixes #251- Implement the delete function and migrate to SHARE versio… #426
Conversation
} | ||
@route = "#{share_config.fetch('host')}api/v2/normalizeddata/" | ||
@body = ShareNotify::Graph.new(document).to_share_v2.to_json | ||
@response = with_timeout { HTTParty.post(@route, body: @body, headers: @headers)} |
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/SpaceInsideBlockBraces: Space missing inside }.
'Authorization' => "Bearer #{share_config.fetch('token')}", | ||
'Content-Type' => 'application/vnd.api+json' | ||
} | ||
@route = "#{share_config.fetch('host')}api/v2/normalizeddata/" |
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.
@headers = { | ||
'Authorization' => "Bearer #{share_config.fetch('token')}", | ||
'Content-Type' => 'application/vnd.api+json' | ||
} |
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/IndentHash: Indent the right brace the same as the start of the line where the left brace is.
osf_contributors(@document).each do |contributor| | ||
document.add_contributor(contributor) | ||
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.
document.title = osf_title(@document) | ||
document.delete | ||
share_upload(document) | ||
redirect_to dams_collection_path(params[:id]), notice: "Your record has been deleted from OSF Share." |
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.
@@ -205,33 +205,44 @@ def osf_data | |||
render :json => @document | |||
end | |||
|
|||
def osf_delete | |||
@document = get_single_doc_via_search(1, {:q => "id:#{params[:id]}"} ) |
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/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
Layout/SpaceInsideParens: Space inside parentheses detected.
|
||
def share_config | ||
env = Rails.env || 'test' | ||
@config ||= YAML.safe_load(ERB.new(IO.read(File.join(Rails.root, 'config', 'share_notify.yml'))).result)[env].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.
Rails/FilePath: Please use Rails.root.join('path', 'to') instead.
def with_timeout(&_block) | ||
Timeout.timeout(5) { yield } | ||
end | ||
def share_upload(document) |
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/IndentationWidth: Use 2 (not 0) spaces for rails indentation.
collection_names.collect! { |name| "\"#{solr_escape(name)}\"" } | ||
solr_param_q = collection_names.join ' OR ' | ||
solr_params = { q: "type_tesim:Collection AND title_tesim:(#{solr_param_q})", rows: collection_names.count } | ||
cols_response, col_documents = get_search_results(solr_params, 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.
Lint/UselessAssignment: Useless assignment to variable - col_documents. Use _ or _col_documents as a variable name to indicate that it won't be used.
relatedResourceData = collectionDoc['related_resource_json_tesim'] unless collectionDoc.nil? | ||
next if relatedResourceData.nil? | ||
relatedResourceData.each do |datum| | ||
relatedResource = JSON.parse(datum) |
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.
collectionDoc = get_single_doc_via_search(1, q: "id:#{collection['id']}") | ||
relatedResourceData = collectionDoc['related_resource_json_tesim'] unless collectionDoc.nil? | ||
next if relatedResourceData.nil? | ||
relatedResourceData.each do |datum| |
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.
Lint/ShadowingOuterLocalVariable: Shadowing outer local variable - datum.
end | ||
end | ||
collectionDoc = get_single_doc_via_search(1, q: "id:#{collection['id']}") | ||
relatedResourceData = collectionDoc['related_resource_json_tesim'] unless collectionDoc.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.
Naming/VariableName: Use snake_case for variable names.
end | ||
end | ||
end | ||
collectionDoc = get_single_doc_via_search(1, q: "id:#{collection['id']}") |
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.
if !collectionData.nil? and collectionData.length > 0 | ||
collectionData.each do |datum| | ||
collectionData = @document['collection_json_tesim'] | ||
@collectionDocArray = [] |
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.
@collectionDocArray = Array.new | ||
if !collectionData.nil? and collectionData.length > 0 | ||
collectionData.each do |datum| | ||
collectionData = @document['collection_json_tesim'] |
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.
facet_collection_names = [] | ||
@facet_collections = @facet_collection_resp[0].facet_counts['facet_fields']['collection_sim'] | ||
if @facet_collections.present? | ||
@facet_collections.each_slice(2) do |collectionName, *_| |
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.
a777b12
to
7bb5359
Compare
def share_upload(document) | ||
@headers = | ||
{ | ||
'Authorization' => "Bearer #{share_config.fetch('token')}", |
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/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
redirect_to dams_collection_path(params[:id]), notice: "Your record has been pushed to OSF Share." | ||
else | ||
redirect_to dams_collection_path(params[:id]), alert: "Your record is not valid." | ||
end | ||
end | ||
|
||
private | ||
def share_upload(document) | ||
@headers = |
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.
'Authorization' => "Bearer #{share_config.fetch('token')}", | ||
'Content-Type' => 'application/vnd.api+json' | ||
} | ||
@route = "#{share_config.fetch('host')}api/v2/normalizeddata/" |
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.
4ab185d
to
c6056f2
Compare
👍 |
1 similar comment
👍 |
@ucsdlib/developers Can anyone merge this PR please? Another ticket #270 is depending on it. Thanks! |
Thank you @ucsdlib/developers for reviewing and @mcritchlow for merged it. |
…n 2 API.
Fixes #251 ; refs #251
Changes proposed in this pull request:
@ucsdlib/developers - please review