Class: Dor::WorkflowIndexer
- Inherits:
-
Object
- Object
- Dor::WorkflowIndexer
- Defined in:
- lib/dor/indexers/workflow_indexer.rb
Overview
Indexes the objects position in workflows
Instance Method Summary collapse
-
#initialize(workflow:) ⇒ WorkflowIndexer
constructor
A new instance of WorkflowIndexer.
-
#to_solr ⇒ Hash
The partial solr document for the workflow document.
Constructor Details
#initialize(workflow:) ⇒ WorkflowIndexer
Returns a new instance of WorkflowIndexer.
14 15 16 |
# File 'lib/dor/indexers/workflow_indexer.rb', line 14 def initialize(workflow:) @workflow = workflow end |
Instance Method Details
#to_solr ⇒ Hash
Returns the partial solr document for the workflow document.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dor/indexers/workflow_indexer.rb', line 19 def to_solr WorkflowSolrDocument.new do |solr_doc| definition = Dor::Config.workflow.client.workflow_template(workflow_name) solr_doc.name = workflow_name processes_names = definition['processes'].map { |p| p['name'] } errors = 0 # The error count is used by the Report class in Argo processes = processes_names.map do |process_name| workflow.process_for_recent_version(name: process_name) end processes.each do |process| index_process(solr_doc, process) errors += 1 if process.status == 'error' end solr_doc.status = [workflow_name, workflow_status(processes), errors, repository].join('|') end end |