Skip to content

Commit

Permalink
fix date_published for aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Aug 7, 2019
1 parent 246a492 commit 291d31b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ def citation_year

def date_published(doi)
## TODO: we need to make sure all the dois from other RA are indexed
doi = Doi.where(doi: doi).first
doi[:published] if doi.present?
item = Doi.where(doi: doi_from_url(doi)).first
item[:publication_year] if item.present?
end

def set_defaults
Expand Down
7 changes: 7 additions & 0 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@
expect(subject.subj["datePublished"]).to eq("2006-06-13T16:14:19Z")
expect(subject.obj["datePublished"]).to be_nil
end

let(:doi) { create(:doi) }

it "date_published from the database" do
published = subject.date_published("https://doi.org/"+doi.doi)
expect(published).to eq(2011)
end
end
end
1 change: 0 additions & 1 deletion spec/requests/events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@
# # let!(:event) { create(:event) }
# # let(:uri) { "/events" }

# TODO: need further setup
context "check meta unique" do
let!(:event) { create_list(:event_for_datacite_related, 5) }
let(:uri) { "/events?aggregations=metrics_aggregations" }
Expand Down

0 comments on commit 291d31b

Please sign in to comment.