Class: BugReportsClient::BugReport

Inherits:
ApplicationRecord show all
Defined in:
app/models/bug_reports_client/bug_report.rb

Overview

Local record of a report submitted to the central bug-reports API. Stores the report for user viewing/editing; the schema-driven answers live in the responses JSON column keyed by field name. Closure updates arrive via the signed webhook and flip status to closed, which surfaces the resolved-report alert until the user dismisses it.

Instance Method Summary collapse

Instance Method Details

#importanceObject

A bug's severity and a feature's priority field are the same "how important is this" rating shown in one list column.



44
45
46
# File 'app/models/bug_reports_client/bug_report.rb', line 44

def importance
  feature? ? response("priority").presence || severity : severity
end

#response(key) ⇒ Object

Reads a single schema-field answer. Keys are always stored as strings.



32
33
34
# File 'app/models/bug_reports_client/bug_report.rb', line 32

def response(key)
  (responses || {})[key.to_s]
end

#responses=(new_responses) ⇒ Object

Merges new answers in rather than replacing, so partial updates (e.g. a type switch that only submits the visible fields) keep earlier answers.



38
39
40
# File 'app/models/bug_reports_client/bug_report.rb', line 38

def responses=(new_responses)
  super((responses || {}).merge((new_responses || {}).stringify_keys))
end

#type_nounObject

Human-readable noun for user-facing copy ("bug report" / "feature request").



49
50
51
# File 'app/models/bug_reports_client/bug_report.rb', line 49

def type_noun
  I18n.t("bug_reports_client.type_nouns.#{report_type.presence || 'bug'}")
end