• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

curationexperts / laevigata / 0d10b93f-7d12-4108-bfd7-303659b33b6c

18 Jun 2025 03:38AM UTC coverage: 97.41% (-0.001%) from 97.411%
0d10b93f-7d12-4108-bfd7-303659b33b6c

Pull #2464

circleci

mark-dce
Disable embargo expiration notifications

Per discussions with SCO, they wish to reduce administrative overhead
by eliminating embargo expiration notifications.

We still need to process actual embargo expirations to change the
corresponding ETDs from a restricted to open status.

Therefore, this change leaves the schedule and service code in place
and simply comments out the calls to notification processing so that
we still get nightly expiration processing.
Pull Request #2464: Disable embargo expiration notifications

4 of 4 new or added lines in 1 file covered. (100.0%)

43 existing lines in 7 files now uncovered.

2821 of 2896 relevant lines covered (97.41%)

52.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.14
/app/jobs/graduation_job.rb
1
require 'workflow_setup'
4✔
2

3
# Everything that needs to happen when a student graduates.
4
# To be called by an automated process that queries the registrar data.
5
# When a student graduates, this job should:
6
# 1. record the student's graduation date
7
# 2. update the embargo relese date, if applicable
8
# 3. submit work to proquest, if applicable
9
# 4. send notifications to approvers, faculty advisors, and depositor
10
class GraduationJob < ActiveJob::Base
4✔
11
  queue_as Hyrax.config.ingest_queue_name
4✔
12

13
  PRIVATE = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
4✔
14
  PUBLIC = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
4✔
15

16
  # @param [String] work_id - the id of the work object
17
  # @param [Date] the student's graduation date
18
  def perform(work_id, graduation_date = Date.current, grad_record = {})
4✔
19
    Rails.logger.warn "ETD #{work_id} starting graduation process"
15✔
20
    @work = Etd.find(work_id)
15✔
21
    record_degree_awarded_date(graduation_date)
15✔
22
    update_embargo_release_date
15✔
23
    update_depositor_email
15✔
24
    publish_object
15✔
25
    ProquestJob.perform_later(@work.id, grad_record) if proquest_eligible?
15✔
26
    send_notifications
15✔
27
    @work.save!
15✔
28
    Rails.logger.warn "ETD #{work_id} finishing graduation process - degree awarded on #{@work.degree_awarded}"
15✔
29
  end
30

31
  def proquest_eligible?
4✔
32
    @work.submit_to_proquest?
12✔
33
  end
34

35
  # @param [Date] graduation_date
36
  def record_degree_awarded_date(graduation_date)
4✔
37
    @work.degree_awarded = graduation_date
15✔
38
    @work.save
15✔
39
  end
40

41
  class UserNotFoundError < RuntimeError; end
4✔
42

43
  # Update the email address of the depositor with their post-graduation email,
44
  # so that we use that for all future notifications
45
  def update_depositor_email
4✔
46
    depositor = ::User.find_by_user_key(@work.depositor)
15✔
47
    raise UserNotFoundError if depositor.nil?
15✔
48
    depositor.email = @work.post_graduation_email.first
12✔
49
    depositor.save
12✔
50
  rescue UserNotFoundError
51
    Honeybadger.notify("ETD #{@work.id}: Could not update post-graduation email address because could not find user with id #{@work.depositor}")
3✔
52
    Rails.logger.error "ETD #{@work.id}: Could not update post-graduation email address because could not find user with id #{@work.depositor}"
3✔
53
  end
54

55
  # Completely remove an embargo, leaving the embargo_history unchanged
56
  def delete_embargo
4✔
57
    if @work.embargo
15✔
UNCOV
58
      @work.embargo.delete
4✔
UNCOV
59
      @work.save
4✔
60
    end
61
    @work.file_sets.each do |fs|
15✔
62
      next unless fs.embargo
6✔
UNCOV
63
      fs.embargo.delete
4✔
UNCOV
64
      fs.visibility = PUBLIC
4✔
UNCOV
65
      fs.save
4✔
66
    end
67
  end
68

69
  # Deactivate an embargo, leaving the prior embargo information in the embargo_history
70
  def deactivate_embargo
4✔
71
    @work.visibility = @work.visibility_after_embargo if @work.visibility_after_embargo
1✔
72
    @work.deactivate_embargo!
1✔
73
    @work.embargo.save
1✔
74
    @work.save
1✔
75
    @work.file_sets.each do |fs|
1✔
76
      fs.visibility = @work.visibility
1✔
77
      fs.deactivate_embargo!
1✔
78
      fs.save
1✔
79
    end
80
    Rails.logger.warn "ETD #{@work.id} post-dated embargo deactivated"
1✔
81
  end
82

83
  def update_embargo_release_date
4✔
84
    delete_embargo # remove any left-over pre-graduation embargo
15✔
85
    return if @work.embargo_length == InProgressEtd::NO_EMBARGO || @work.embargo_length.nil?
15✔
86

87
    # Apply the requested embargo calculated from the graduation date
UNCOV
88
    embargo_release_date = GraduationHelper.embargo_length_to_embargo_release_date(@work.degree_awarded, @work.embargo_length)
3✔
UNCOV
89
    @work.apply_embargo(embargo_release_date, PUBLIC, PUBLIC)
3✔
UNCOV
90
    @work.file_sets.each do |fs|
3✔
UNCOV
91
      fs.apply_embargo(embargo_release_date, PRIVATE, PUBLIC)
3✔
UNCOV
92
      fs.save
3✔
93
    end
UNCOV
94
    Rails.logger.warn "ETD #{@work.id} embargo release date set to #{embargo_release_date}"
3✔
95

UNCOV
96
    deactivate_embargo if embargo_release_date <= Time.zone.today
3✔
97

98
  rescue => e
99
    Rails.logger.error "Error updating embargo release date for work #{@work}: #{e}"
×
100
    Honeybadger.notify("Error updating embargo release date for work #{@work}: #{e}")
×
101
  end
102

103
  def send_notifications
4✔
104
    work_global_id = @work.to_global_id.to_s
12✔
105
    entity = Sipity::Entity.where(proxy_for_global_id: work_global_id).first
12✔
106
    Hyrax::Workflow::DegreeAwardedNotification.send_notification(entity: entity, comment: '', user: ::User.where(ppid: WorkflowSetup::NOTIFICATION_OWNER).first)
12✔
107
  end
108

109
  # Transition the workflow of this object to the "published" workflow state
110
  # This should also mark it as active.
111
  def publish_object
4✔
112
    approving_user = ::User.find_by_uid(WorkflowSetup::ADMIN_SET_OWNER)
12✔
113
    subject = Hyrax::WorkflowActionInfo.new(@work, approving_user)
12✔
114
    sipity_workflow_action = PowerConverter.convert_to_sipity_action("publish", scope: subject.entity.workflow) { nil }
12✔
115
    Hyrax::Workflow::WorkflowActionService.run(subject: subject, action: sipity_workflow_action, comment: "Published by graduation job #{Time.zone.today}")
12✔
116
    Rails.logger.warn "ETD #{@work.id} published via WorkflowActionService"
12✔
117
  end
118
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc