-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix for duplicate ids appearing in connections when events contain uppercase and lowercase source_ids and target_ids #1233
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1273,30 +1273,30 @@ def downloads_over_time | |
end | ||
|
||
def reference_ids | ||
reference_events.pluck(:target_doi).compact.uniq.map(&:downcase) | ||
reference_events.pluck(:target_doi).compact.map(&:downcase).uniq | ||
end | ||
|
||
def reference_count | ||
reference_events.pluck(:target_doi).uniq.length | ||
reference_events.pluck(:target_doi).compact.map(&:downcase).uniq.length | ||
end | ||
|
||
def indexed_references | ||
Doi.query(nil, ids: reference_ids, page: { number: 1, size: 25 }).results | ||
end | ||
|
||
def citation_ids | ||
citation_events.pluck(:source_doi).compact.uniq.map(&:downcase) | ||
citation_events.pluck(:source_doi).compact.map(&:downcase).uniq | ||
end | ||
|
||
# remove duplicate citing source dois | ||
def citation_count | ||
citation_events.pluck(:source_doi).uniq.length | ||
citation_events.pluck(:source_doi).compact.map(&:downcase).uniq.length | ||
end | ||
|
||
# remove duplicate citing source dois, | ||
# then show distribution by year | ||
def citations_over_time | ||
citation_events.pluck(:occurred_at, :source_doi).uniq { |v| v[1] }. | ||
citation_events.pluck(:occurred_at, :source_doi).map { |v| [v[0], v[1].downcase] }.sort_by { |v| v[0] }.uniq { |v| v[1] }. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wendelfabianchinsamy I just added back the |
||
group_by { |v| v[0].utc.iso8601[0..3] }. | ||
map { |k, v| { "year" => k, "total" => v.length } }. | ||
sort_by { |h| h["year"] } | ||
|
@@ -1307,47 +1307,47 @@ def indexed_citations | |
end | ||
|
||
def part_ids | ||
part_events.pluck(:target_doi).compact.uniq.map(&:downcase) | ||
part_events.pluck(:target_doi).compact.map(&:downcase).uniq | ||
end | ||
|
||
def part_count | ||
part_events.pluck(:target_doi).uniq.length | ||
part_events.pluck(:target_doi).compact.map(&:downcase).uniq.length | ||
end | ||
|
||
def indexed_parts | ||
Doi.query(nil, ids: part_ids, page: { number: 1, size: 25 }).results.to_a | ||
end | ||
|
||
def part_of_ids | ||
part_of_events.pluck(:source_doi).compact.uniq.map(&:downcase) | ||
part_of_events.pluck(:source_doi).compact.map(&:downcase).uniq | ||
end | ||
|
||
def part_of_count | ||
part_of_events.pluck(:source_doi).uniq.length | ||
part_of_events.pluck(:source_doi).compact.map(&:downcase).uniq.length | ||
end | ||
|
||
def indexed_part_of | ||
Doi.query(nil, ids: part_of_ids, page: { number: 1, size: 25 }).results | ||
end | ||
|
||
def version_ids | ||
version_events.pluck(:target_doi).compact.uniq.map(&:downcase) | ||
version_events.pluck(:target_doi).compact.map(&:downcase).uniq | ||
end | ||
|
||
def version_count | ||
version_events.pluck(:target_doi).uniq.length | ||
version_events.pluck(:target_doi).compact.map(&:downcase).uniq.length | ||
end | ||
|
||
def indexed_versions | ||
Doi.query(nil, ids: version_ids, page: { number: 1, size: 25 }).results | ||
end | ||
|
||
def version_of_ids | ||
version_of_events.pluck(:source_doi).compact.uniq.map(&:downcase) | ||
version_of_events.pluck(:source_doi).compact.map(&:downcase).uniq | ||
end | ||
|
||
def version_of_count | ||
version_of_events.pluck(:source_doi).uniq.length | ||
version_of_events.pluck(:source_doi).compact.map(&:downcase).uniq.length | ||
end | ||
|
||
def indexed_version_of | ||
|
@@ -1361,11 +1361,11 @@ def other_relation_events | |
def other_relation_ids | ||
other_relation_events.map do |e| | ||
e.doi | ||
end.flatten.uniq - [doi.downcase] | ||
end.flatten.compact.map(&:downcase).uniq - [doi.downcase] | ||
end | ||
|
||
def other_relation_count | ||
other_relation_ids.length | ||
other_relation_ids.compact.map(&:downcase).length | ||
end | ||
|
||
def xml_encoded | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@codycooperross the only suggestion I would make is not exactly to do with your change but with the existing code repetition. This happens in a few places but if you look at the method reference_count it's code is exactly the same as reference_ids except for the additional length method invocation. Because we didn't reuse the code we had to make this change in two places.
This is certainly outside the scope of your PR. I will create an issue to clean up this code to make more DRY (don't repeat yourself).
I will approve this PR.
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.
Thank you, Wendel!