Class: Debci::Package
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Debci::Package
- Defined in:
- lib/debci/package.rb
Overview
This class represents a single package.
Class Method Summary collapse
Instance Method Summary collapse
-
#fail_or_neutral ⇒ Object
Returns an Array of statuses where this package is failing or neutral.
-
#history(suite, architecture) ⇒ Object
Returns an array of Debci::Job objects that represent the test history for this package.
- #last_updated_at(suite = nil) ⇒ Object
- #news ⇒ Object
- #prefix ⇒ Object
- #reject_list_comment(params = {}) ⇒ Object
- #reject_listed?(params = {}) ⇒ Boolean
-
#status ⇒ Object
Returns a matrix of Debci::Job objects, where rows represent architectures and columns represent suites:.
- #to_s ⇒ Object
- #to_str ⇒ Object
Class Method Details
.prefix(name) ⇒ Object
111 112 113 114 |
# File 'lib/debci/package.rb', line 111 def self.prefix(name) name =~ /^((lib)?.)/ Regexp.last_match(1) end |
.prefixes ⇒ Object
106 107 108 109 |
# File 'lib/debci/package.rb', line 106 def self.prefixes # FIXME: optimize(?) select(:name).distinct.pluck(:name).map { |n| prefix(n) }.sort.uniq end |
Instance Method Details
#fail_or_neutral ⇒ Object
Returns an Array of statuses where this package is failing or neutral.
92 93 94 |
# File 'lib/debci/package.rb', line 92 def fail_or_neutral status.flatten.compact.select { |p| (p.status.to_sym == :fail) || (p.status.to_sym == :neutral) } end |
#history(suite, architecture) ⇒ Object
Returns an array of Debci::Job objects that represent the test history for this package
52 53 54 |
# File 'lib/debci/package.rb', line 52 def history(suite, architecture) Debci::Job.history(self, suite, architecture) end |
#last_updated_at(suite = nil) ⇒ Object
128 129 130 131 |
# File 'lib/debci/package.rb', line 128 def last_updated_at(suite = nil) statuses = status.flatten.compact.select { |s| s.suite == suite || !suite } statuses.map(&:date).compact.max end |
#news ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/debci/package.rb', line 56 def news limit = 10 result = [] current = {} candidates = jobs.where.not(status: [nil, 'tmpfail']).where(pin_packages: nil) candidates = candidates.order('date DESC') # This manually written batch iteration can be replaced by # ActiveRecord::Base.find_in_batches(cursor: :date, order: :desc) with # ActiveRecord 8. ActiveRecord 7 does not allow to control the batch # ordering and orders on the primary key unconditionally. offset = 0 window = 100 while result.length < limit items = 0 candidates.offset(offset).limit(window).each do |job| key = [job.suite, job.arch].join('/') current_job = current[key] if current_job && current_job.status != job.status result << current_job end break if result.size >= limit current[key] = job items += 1 end offset += window break if items == 0 end result end |
#prefix ⇒ Object
116 117 118 |
# File 'lib/debci/package.rb', line 116 def prefix self.class.prefix(name) end |
#reject_list_comment(params = {}) ⇒ Object
124 125 126 |
# File 'lib/debci/package.rb', line 124 def reject_list_comment(params = {}) Debci.reject_list.comment(name, params) end |
#reject_listed?(params = {}) ⇒ Boolean
120 121 122 |
# File 'lib/debci/package.rb', line 120 def reject_listed?(params = {}) Debci.reject_list.include?(name, params) end |
#status ⇒ Object
Returns a matrix of Debci::Job objects, where rows represent architectures and columns represent suites:
[
[ amd64_unstable , amd64_testing ],
[ i386_unstable, i386_testing ],
]
Each cell of the matrix contains a Debci::Job object. Note: Contains statuses which are not rejectlisted
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/debci/package.rb', line 35 def status @status ||= begin map = package_status.includes(:job).each_with_object({}) do |st, memo| memo[st.arch] ||= {} memo[st.arch][st.suite] = st.job end Debci.config.arch_list.map do |arch| Debci.config.suite_list.map do |suite| map[arch] && map[arch][suite] end end end end |
#to_s ⇒ Object
96 97 98 99 |
# File 'lib/debci/package.rb', line 96 def to_s # :nodoc: "<Package #{name}>" end |
#to_str ⇒ Object
101 102 103 104 |
# File 'lib/debci/package.rb', line 101 def to_str # :nodoc: name end |