Skip to content

Commit

Permalink
Merge pull request #1035 from psu-libraries/1027-oa-emails
Browse files Browse the repository at this point in the history
oa email notifications- filter out pubs with an associated AI OA file
  • Loading branch information
Smullz622 authored Dec 6, 2024
2 parents a850832 + e39c729 commit 7256d6b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def self.needs_open_access_notification
.where('publications.published_on >= user_organization_memberships.started_on AND (publications.published_on <= user_organization_memberships.ended_on OR user_organization_memberships.ended_on IS NULL)')
.where('authorships.confirmed IS TRUE')
.where('publications.visible = true')
.where('publications.activity_insight_postprint_status IS NULL OR publications.activity_insight_postprint_status != ?', 'In Progress')
.where('publications.id NOT IN (SELECT publication_id FROM activity_insight_oa_files)')
.where("open_access_locations.id IS NULL OR open_access_locations.url = ''")
.distinct(:id)
end
Expand Down Expand Up @@ -283,6 +283,7 @@ def potential_open_access_publications
.published_during_membership
.subject_to_open_access_policy
.where('authorships.confirmed IS TRUE')
.where('publications.id NOT IN (SELECT publication_id FROM activity_insight_oa_files)')
end

def psu_identity_data
Expand Down
30 changes: 25 additions & 5 deletions spec/component/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
user: email_user_1,
started_on: Date.new(2019, 1, 1),
ended_on: nil) }
let!(:eu_pub_1) { create(:publication, published_on: Date.new(2020, 7, 1), activity_insight_postprint_status: 'Cannot Deposit') }
let!(:eu_pub_1) { create(:publication, published_on: Date.new(2020, 7, 1)) }
let!(:eu_auth_1) { create(:authorship,
user: email_user_1,
publication: eu_pub_1,
Expand All @@ -472,7 +472,7 @@
user: email_user_2,
started_on: Date.new(2019, 1, 1),
ended_on: nil) }
let!(:eu_pub_2) { create(:publication, published_on: Date.new(2020, 7, 1), activity_insight_postprint_status: 'Cannot Deposit') }
let!(:eu_pub_2) { create(:publication, published_on: Date.new(2020, 7, 1)) }
let!(:eu_auth_2) { create(:authorship,
user: email_user_2,
publication: eu_pub_2,
Expand All @@ -496,7 +496,7 @@
user: email_user_3,
started_on: Date.new(2019, 1, 1),
ended_on: Date.new(2020, 7, 2)) }
let!(:eu_pub_3) { create(:publication, published_on: Date.new(2020, 7, 1), activity_insight_postprint_status: 'Cannot Deposit') }
let!(:eu_pub_3) { create(:publication, published_on: Date.new(2020, 7, 1)) }
let!(:eu_auth_3) { create(:authorship,
user: email_user_3,
publication: eu_pub_3,
Expand Down Expand Up @@ -794,15 +794,16 @@
publication: ou_pub_17,
confirmed: true) }

# filtered out due to the publication being in process of deposit to Scholarsphere via AI (activity_insight_postprint_status is 'In Progress')
# filtered out due to the publication being in the Activity Insight OA Workflow (has activity_insight_oa_file)
let!(:other_user_18) { create(:user, :with_psu_identity,
open_access_notification_sent_at: 1.year.ago,
first_name: 'other_user_18') }
let!(:ou_mem_18) { create(:user_organization_membership,
user: other_user_18,
started_on: Date.new(2019, 1, 1),
ended_on: nil)}
let!(:ou_pub_18) { create(:publication, published_on: Date.new(2020, 7, 1), activity_insight_postprint_status: 'In Progress') }
let!(:ou_pub_18) { create(:publication, published_on: Date.new(2020, 7, 1)) }
let!(:ou_aif18) { create(:activity_insight_oa_file, publication: ou_pub_18, version: 'publishedVersion', user: other_user_18) }
let!(:ou_auth_18) { create(:authorship,
user: other_user_18,
publication: ou_pub_18,
Expand Down Expand Up @@ -866,6 +867,16 @@
confirmed: true,
open_access_notification_sent_at: 1.month.ago) }

# Filtered out due to being in the Activity Insight OA Workflow (has activity_insight_oa_file)
let!(:other_pub_2) { create(:publication,
published_on: Date.new(2020, 7, 1)) }
let!(:o_auth_2) { create(:authorship,
user: user,
publication: other_pub_2,
confirmed: true,
open_access_notification_sent_at: 1.month.ago) }
let!(:o_aif_2) { create(:activity_insight_oa_file, publication: other_pub_2, version: 'publishedVersion', user: user) }

# Filtered out due to presence of open_access_url
let!(:other_pub_5) { create(:publication,
published_on: Date.new(2020, 7, 1),
Expand Down Expand Up @@ -1035,6 +1046,15 @@
user: user,
publication: other_pub_1,
confirmed: true) }
# Filtered out due to being in the Activity Insight OA Workflow (has activity_insight_oa_file)
let!(:other_pub_2) { create(:publication,
published_on: Date.new(2020, 7, 1)) }
let!(:o_auth_2) { create(:authorship,
user: user,
publication: other_pub_2,
confirmed: true,
open_access_notification_sent_at: 1.month.ago) }
let!(:o_aif_2) { create(:activity_insight_oa_file, publication: other_pub_2, version: 'publishedVersion', user: user) }

# Filtered out due to presence of open_access_url
let!(:other_pub_5) { create(:publication,
Expand Down

0 comments on commit 7256d6b

Please sign in to comment.