Class: Zizq::Resources::JobPage

Inherits:
Page show all
Defined in:
lib/zizq/resources/job_page.rb,
sig/generated/zizq/resources/job_page.rbs

Overview

Paginated list of jobs.

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Page

#each, #has_next?, #has_prev?, #next_page, #prev_page, #to_h, #wrap_page

Methods inherited from Resource

#initialize, #inspect, #ms_to_seconds, #to_h

Constructor Details

This class inherits a constructor from Zizq::Resources::Resource

Instance Method Details

#delete_allInteger

Delete all jobs on this page.

Returns the number of deleted jobs.

RBS:

  • return: Integer

Returns:

  • (Integer)


23
24
25
26
27
28
# File 'lib/zizq/resources/job_page.rb', line 23

def delete_all
  ids = jobs.map(&:id)
  return 0 if ids.empty?

  client.delete_all_jobs(where: { id: ids })
end

#itemsObject Also known as: jobs

Signature:

  • () -> Array[Job]

Returns:

  • (Object)


12
13
14
# File 'lib/zizq/resources/job_page.rb', line 12

def items #: () -> Array[Job]
  @items ||= (@data["jobs"] || []).map { |j| Job.new(client, j) }
end

#update_all(queue: Zizq::UNCHANGED, priority: Zizq::UNCHANGED, ready_at: Zizq::UNCHANGED, retry_limit: Zizq::UNCHANGED, backoff: Zizq::UNCHANGED, retention: Zizq::UNCHANGED) ⇒ Integer

Update all jobs on this page with the given field values.

Returns the number of updated jobs.

RBS:

  • queue: (String | singleton(Zizq::UNCHANGED))?

  • priority: (Integer | singleton(Zizq::UNCHANGED))?

  • ready_at: (Zizq::to_f | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?

  • retry_limit: (Integer | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?

  • backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?

  • retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?

  • return: Integer

Parameters:

Returns:

  • (Integer)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/zizq/resources/job_page.rb', line 41

def update_all(
  queue: Zizq::UNCHANGED,
  priority: Zizq::UNCHANGED,
  ready_at: Zizq::UNCHANGED,
  retry_limit: Zizq::UNCHANGED,
  backoff: Zizq::UNCHANGED,
  retention: Zizq::UNCHANGED
)
  ids = jobs.map(&:id)
  return 0 if ids.empty?

  client.update_all_jobs(
    where: {
      id: ids
    },
    apply: {
      queue:,
      priority:,
      ready_at:,
      retry_limit:,
      backoff:,
      retention:
    }
  )
end