Class: DwcOccurrenceRefreshJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/dwc_occurrence_refresh_job.rb

Instance Method Summary collapse

Instance Method Details

#max_attemptsObject



8
9
10
# File 'app/jobs/dwc_occurrence_refresh_job.rb', line 8

def max_attempts
  2
end

#max_run_timeObject



4
5
6
# File 'app/jobs/dwc_occurrence_refresh_job.rb', line 4

def max_run_time
  2.hours
end

#perform(rebuild_set: nil, user_id: nil) ⇒ Object

Raises:

  • (TaxonWorks::Error)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/jobs/dwc_occurrence_refresh_job.rb', line 14

def perform(rebuild_set: nil, user_id: nil)
  raise TaxonWorks::Error, 'no set id to refresh job' if rebuild_set.blank?

  q = DwcOccurrence
    .where(rebuild_set:)
    .includes(
      dwc_occurrence_object: [
        :images,
        :identifiers,
        :type_materials,
        :preparation_type,
        :taxon_determinations,
        :current_taxon_determination,
        :biocuration_classifications,
        { collecting_event: [:georeferences, { collector_roles: :person }, :geographic_area] }
      ]
    )

  q.find_each do |o|

    begin
      o.dwc_occurrence_object.send(:set_dwc_occurrence)
    rescue => ex
      ExceptionNotifier.notify_exception(
        ex,
        data: { user_id:}
      )
      raise
    end
  end

end