Class: Legion::Cli::Task
- Inherits:
-
Thor
- Object
- Thor
- Legion::Cli::Task
- Defined in:
- lib/legion/cli/task.rb
Instance Method Summary collapse
Instance Method Details
#logs(id) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/legion/cli/task.rb', line 27 def logs(id) Legion::Service.new(cache: false, crypt: false, extensions: false, log_level: 'error') rows = [%w[id node_id created entry]] Legion::Data::Model::TaskLog.where(task_id: id).limit([:limit]).each do |row| rows.push([row.values[:id], row.values[:node_id], row.values[:created], row.values[:entry]]) end print_table rows end |
#purge ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/legion/cli/task.rb', line 37 def purge Legion::Service.new(cache: false, crypt: false, extensions: false, log_level: 'error') days = ask 'how many days do you want to keep?', default: 7 dataset = Legion::Data::Model::Task.where { created < DateTime.now - days.to_i } yes? "This will delete #{dataset.count} tasks, continue?", :red dataset.delete say 'Done!' end |
#show ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/legion/cli/task.rb', line 9 def show Legion::Service.new(cache: false, crypt: false, extensions: false, log_level: 'error') rows = [%w[id relationship function status]] Legion::Data::Model::Task.limit([:limit]).order(:id).reverse_each do |row| rows.push([row.values[:id], row.values[:relationship_id], row.values[:function_id], row.values[:status]]) end print_table rows end |