Class: Afterlife::Clickup::UpdateTaskStatus
- Inherits:
-
Object
- Object
- Afterlife::Clickup::UpdateTaskStatus
- Defined in:
- lib/afterlife/clickup/update_task_status.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#cherry_pick ⇒ Object
readonly
Returns the value of attribute cherry_pick.
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#revert_detector ⇒ Object
readonly
Returns the value of attribute revert_detector.
-
#slack_output_path ⇒ Object
readonly
Returns the value of attribute slack_output_path.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(task_ids, target_status) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(force: false, dry_run: false, cherry_pick: false, verbose: true, commits: nil) ⇒ UpdateTaskStatus
constructor
A new instance of UpdateTaskStatus.
Constructor Details
#initialize(force: false, dry_run: false, cherry_pick: false, verbose: true, commits: nil) ⇒ UpdateTaskStatus
Returns a new instance of UpdateTaskStatus.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 14 def initialize(force: false, dry_run: false, cherry_pick: false, verbose: true, commits: nil) @force = force @dry_run = dry_run @cherry_pick = cherry_pick @verbose = verbose @slack_output_path = ENV.fetch('AFTERLIFE_SLACK_OUTPUT', nil) write_slack_output('') if slack_output_path @revert_detector = TaskRevertDetector.new(commits) token = ENV['CLICKUP_TOKEN'] || fail('CLICKUP_TOKEN required, put `export CLICKUP_TOKEN=...` or the equivalent in your shell') # rubocop:disable Layout/LineLength @api = Api.new(token:) end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def api @api end |
#cherry_pick ⇒ Object (readonly)
Returns the value of attribute cherry_pick.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def cherry_pick @cherry_pick end |
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def dry_run @dry_run end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def force @force end |
#revert_detector ⇒ Object (readonly)
Returns the value of attribute revert_detector.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def revert_detector @revert_detector end |
#slack_output_path ⇒ Object (readonly)
Returns the value of attribute slack_output_path.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def slack_output_path @slack_output_path end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def verbose @verbose end |
Class Method Details
.call(task_ids, target_status, force: false, dry_run: false, cherry_pick: false, verbose: true, commits: nil) ⇒ Object
8 9 10 11 12 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 8 def self.call( task_ids, target_status, force: false, dry_run: false, cherry_pick: false, verbose: true, commits: nil ) new(force:, dry_run:, cherry_pick:, verbose:, commits:).call(task_ids, target_status) end |
Instance Method Details
#call(task_ids, target_status) ⇒ Object
rubocop:disable Metrics/AbcSize
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 26 def call(task_ids, target_status) # rubocop:disable Metrics/AbcSize if task_ids.empty? log 'No tasks to update' return [] end log 'WARNING: Forcing status updates...' if force log 'WARNING: Dry run, no tasks will be updated' if dry_run log "#{dry_run ? 'Would update' : 'Updating'} #{task_ids.length} tasks to '#{target_status}'" moved_task_ids = task_ids.map { |task_id| move_task(task_id, target_status) }.compact log "#{dry_run ? 'Would have moved' : 'Moved'} #{moved_task_ids.length} tasks:" moved_task_ids.each do |task| cherry_pick_status = " - Cherry Pick: #{task[:is_cherry_pick] ? '✅' : '❌'}" if cherry_pick log "- #{task[:link]} (from '#{task[:previous_status]}' to '#{task[:new_status]}')#{cherry_pick_status}" end moved_task_ids end |