2022-04-19 02:37:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-04-01 13:36:20 -05:00
|
|
|
class Cve < ActiveRecord::Base
|
2022-04-19 02:37:27 -05:00
|
|
|
scope :with_reserved, -> { where("cve_data_meta->>'STATE' = 'RESERVED'") }
|
|
|
|
scope :without_reserved, -> { where.not("cve_data_meta->>'STATE' = 'RESERVED'") }
|
|
|
|
scope :with_rejected, -> { where("cve_data_meta->>'STATE' = 'REJECT'") }
|
|
|
|
scope :without_rejected, -> { where.not("cve_data_meta->>'STATE' = 'REJECT'") }
|
|
|
|
scope :with_public, -> { where("cve_data_meta->>'STATE' = 'PUBLIC'") }
|
|
|
|
scope :without_public, -> { where.not("cve_data_meta->>'STATE' = 'PUBLIC'") }
|
|
|
|
|
|
|
|
def self.find_by_id(id)
|
|
|
|
find_by(cve_id: id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.from_year(year)
|
|
|
|
where('cve_id LIKE ?', "CVE-#{year}-%")
|
|
|
|
end
|
2022-04-01 13:36:20 -05:00
|
|
|
end
|