Class: Aidp::Watch::WorkItem
- Inherits:
-
Object
- Object
- Aidp::Watch::WorkItem
- Includes:
- Comparable
- Defined in:
- lib/aidp/watch/work_item.rb
Overview
Value object representing a work item in the round-robin queue. Encapsulates issue/PR data with metadata needed for scheduling.
Constant Summary collapse
- ITEM_TYPES =
%i[issue pr].freeze
- PROCESSOR_TYPES =
%i[plan build auto_issue review ci_fix auto_pr change_request].freeze
- PRIORITY_PLAN =
Priority levels for scheduling (lower = higher priority)
1- PRIORITY_NORMAL =
2
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#item_type ⇒ Object
readonly
Returns the value of attribute item_type.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#processor_type ⇒ Object
readonly
Returns the value of attribute processor_type.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Comparison for sorting by priority.
-
#initialize(number:, item_type:, processor_type:, label:, data:, priority: nil) ⇒ WorkItem
constructor
A new instance of WorkItem.
-
#issue? ⇒ Boolean
Check if item is an issue (vs PR).
-
#key ⇒ String
Unique key for this work item (used for queue tracking).
-
#plan? ⇒ Boolean
Check if this is a high-priority plan item.
-
#pr? ⇒ Boolean
Check if item is a PR.
-
#same_entity?(other) ⇒ Boolean
Check if this work item is for the same issue/PR.
- #to_h ⇒ Object
Constructor Details
#initialize(number:, item_type:, processor_type:, label:, data:, priority: nil) ⇒ WorkItem
Returns a new instance of WorkItem.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/aidp/watch/work_item.rb', line 19 def initialize(number:, item_type:, processor_type:, label:, data:, priority: nil) validate_item_type!(item_type) validate_processor_type!(processor_type) @number = number @item_type = item_type @processor_type = processor_type @label = label @data = data @priority = priority || default_priority end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
17 18 19 |
# File 'lib/aidp/watch/work_item.rb', line 17 def data @data end |
#item_type ⇒ Object (readonly)
Returns the value of attribute item_type.
17 18 19 |
# File 'lib/aidp/watch/work_item.rb', line 17 def item_type @item_type end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
17 18 19 |
# File 'lib/aidp/watch/work_item.rb', line 17 def label @label end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
17 18 19 |
# File 'lib/aidp/watch/work_item.rb', line 17 def number @number end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
17 18 19 |
# File 'lib/aidp/watch/work_item.rb', line 17 def priority @priority end |
#processor_type ⇒ Object (readonly)
Returns the value of attribute processor_type.
17 18 19 |
# File 'lib/aidp/watch/work_item.rb', line 17 def processor_type @processor_type end |
Instance Method Details
#<=>(other) ⇒ Object
Comparison for sorting by priority
73 74 75 |
# File 'lib/aidp/watch/work_item.rb', line 73 def <=>(other) priority <=> other.priority end |
#issue? ⇒ Boolean
Check if item is an issue (vs PR)
46 47 48 |
# File 'lib/aidp/watch/work_item.rb', line 46 def issue? item_type == :issue end |
#key ⇒ String
Unique key for this work item (used for queue tracking)
33 34 35 |
# File 'lib/aidp/watch/work_item.rb', line 33 def key "#{item_type}_#{number}_#{processor_type}" end |
#plan? ⇒ Boolean
Check if this is a high-priority plan item
58 59 60 |
# File 'lib/aidp/watch/work_item.rb', line 58 def plan? processor_type == :plan end |
#pr? ⇒ Boolean
Check if item is a PR
52 53 54 |
# File 'lib/aidp/watch/work_item.rb', line 52 def pr? item_type == :pr end |
#same_entity?(other) ⇒ Boolean
Check if this work item is for the same issue/PR
40 41 42 |
# File 'lib/aidp/watch/work_item.rb', line 40 def same_entity?(other) item_type == other.item_type && number == other.number end |
#to_h ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/aidp/watch/work_item.rb', line 62 def to_h { number: number, item_type: item_type, processor_type: processor_type, label: label, priority: priority } end |