2019-12-06 04:06:39 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-01-29 07:09:08 -05:00
|
|
|
class SentryErrorPresenter < Gitlab::View::Presenter::Delegated
|
2019-12-06 04:06:39 -05:00
|
|
|
presents :error
|
|
|
|
|
|
|
|
FrequencyStruct = Struct.new(:time, :count, keyword_init: true)
|
|
|
|
|
2020-01-29 07:09:08 -05:00
|
|
|
def first_seen
|
|
|
|
DateTime.parse(error.first_seen)
|
|
|
|
end
|
|
|
|
|
|
|
|
def last_seen
|
|
|
|
DateTime.parse(error.last_seen)
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_id
|
2020-09-21 05:09:29 -04:00
|
|
|
Gitlab::GlobalId.build(model_name: 'SentryProject', id: error.project_id).to_s
|
2020-01-29 07:09:08 -05:00
|
|
|
end
|
|
|
|
|
2019-12-06 04:06:39 -05:00
|
|
|
def frequency
|
|
|
|
utc_offset = Time.zone_offset('UTC')
|
|
|
|
|
|
|
|
error.frequency.map do |f|
|
|
|
|
FrequencyStruct.new(time: Time.at(f[0], in: utc_offset), count: f[1])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|