Skip to content

Commit

Permalink
automatically track metrics for works mentioned in the body of anothe…
Browse files Browse the repository at this point in the history
…r work. Closes #336
  • Loading branch information
Martin Fenner committed Jun 17, 2015
1 parent 4a2aeae commit ca6c3ff
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/sources/bmc_fulltext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def get_related_works(result, work)
"timestamp" => timestamp,
"DOI" => doi,
"type" => "article-journal",
"tracked" => true,
"related_works" => [{ "related_work" => work.pid,
"source" => name,
"relation_type" => "cites" }] }
Expand Down
25 changes: 25 additions & 0 deletions app/models/sources/europe_pmc_fulltext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ def get_query_string(work)
end
end

def get_related_works(result, work)
result.fetch("#{result_key}List", {}).fetch(result_key, []).map do |item|
pmid = item.fetch(pmid_key, nil)
ids = get_persistent_identifiers(pmid, "pmid")
ids = {} unless ids.is_a?(Hash)
doi = ids.fetch("doi", nil)
pmcid = ids.fetch("pmcid", nil)
pmcid = pmcid[3..-1] if pmcid
author_string = item.fetch("authorString", "").chomp(".")

{ "author" => get_authors(author_string.split(", "), reversed: true),
"title" => item.fetch("title", "").chomp("."),
"container-title" => item.fetch(container_title_key, nil),
"issued" => get_date_parts_from_parts(item.fetch("pubYear", nil)),
"DOI" => doi,
"PMID" => pmid,
"PMCID" => pmcid,
"type" => "article-journal",
"tracked" => true,
"related_works" => [{ "related_work" => work.pid,
"source" => name,
"relation_type" => "cites" }] }
end
end

def config_fields
[:url, :events_url]
end
Expand Down
1 change: 1 addition & 0 deletions app/models/sources/nature_opensearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def get_related_works(result, work)
"DOI" => doi,
"URL" => url,
"type" => "article-journal",
"tracked" => true,
"related_works" => [{ "related_work" => work.pid,
"source" => name,
"relation_type" => "cites" }] }
Expand Down
1 change: 1 addition & 0 deletions app/models/sources/plos_fulltext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def get_related_works(result, work)
"timestamp" => timestamp,
"DOI" => doi,
"type" => "article-journal",
"tracked" => true,
"related_works" => [{ "related_work" => work.pid,
"source" => name,
"relation_type" => "cites" }] }
Expand Down

0 comments on commit ca6c3ff

Please sign in to comment.