Module: Legion::Extensions::Rfp::Review::Runners::Workflows
- Extended by:
- Helpers::Client
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/rfp/review/runners/workflows.rb
Constant Summary collapse
- STATUSES =
%i[draft in_review revision_requested approved rejected finalized].freeze
Instance Method Summary collapse
- #create_workflow(proposal_id:, sections: [], reviewers: []) ⇒ Object
- #finalize(workflow_id:) ⇒ Object
- #get_workflow(workflow_id:) ⇒ Object
- #submit_for_review(workflow_id:, reviewers:) ⇒ Object
- #update_section_status(workflow_id:, section_name:, status:, reviewer: nil) ⇒ Object
- #update_status(workflow_id:, status:) ⇒ Object
Methods included from Helpers::Client
Instance Method Details
#create_workflow(proposal_id:, sections: [], reviewers: []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/rfp/review/runners/workflows.rb', line 13 def create_workflow(proposal_id:, sections: [], reviewers: [], **) workflow = { id: generate_workflow_id, proposal_id: proposal_id, status: :draft, sections: sections.map { |s| { name: s, status: :draft, reviewer: nil, comments: [] } }, reviewers: reviewers, created_at: Time.now.iso8601, updated_at: Time.now.iso8601 } { result: workflow } end |
#finalize(workflow_id:) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/legion/extensions/rfp/review/runners/workflows.rb', line 63 def finalize(workflow_id:, **) { result: { workflow_id: workflow_id, status: :finalized, finalized_at: Time.now.iso8601 } } end |
#get_workflow(workflow_id:) ⇒ Object
26 27 28 |
# File 'lib/legion/extensions/rfp/review/runners/workflows.rb', line 26 def get_workflow(workflow_id:, **) { result: { id: workflow_id, status: :draft }, error: 'Persistence requires legion-data' } end |
#submit_for_review(workflow_id:, reviewers:) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/legion/extensions/rfp/review/runners/workflows.rb', line 52 def submit_for_review(workflow_id:, reviewers:, **) { result: { workflow_id: workflow_id, status: :in_review, reviewers: reviewers, submitted_at: Time.now.iso8601 } } end |
#update_section_status(workflow_id:, section_name:, status:, reviewer: nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/legion/extensions/rfp/review/runners/workflows.rb', line 37 def update_section_status(workflow_id:, section_name:, status:, reviewer: nil, **) status_sym = status.to_sym return { result: nil, error: "Invalid status: #{status}" } unless STATUSES.include?(status_sym) { result: { workflow_id: workflow_id, section: section_name, status: status_sym, reviewer: reviewer, updated_at: Time.now.iso8601 } } end |
#update_status(workflow_id:, status:) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/legion/extensions/rfp/review/runners/workflows.rb', line 30 def update_status(workflow_id:, status:, **) status_sym = status.to_sym return { result: nil, error: "Invalid status: #{status}. Valid: #{STATUSES.join(', ')}" } unless STATUSES.include?(status_sym) { result: { id: workflow_id, status: status_sym, updated_at: Time.now.iso8601 } } end |