Module: OnlyofficeBugzillaHelper::BugData

Included in:
BugzillaHelper
Defined in:
lib/onlyoffice_bugzilla_helper/bug_data.rb

Overview

Method to work with bug data

Instance Method Summary collapse

Instance Method Details

#bug_data(bug_id) ⇒ JSON

Get bug data of bug

Parameters:

  • bug_id (String, Integer)

    id of bug

Returns:

  • (JSON)

    data



9
10
11
12
# File 'lib/onlyoffice_bugzilla_helper/bug_data.rb', line 9

def bug_data(bug_id)
  res = get_bug_result(bug_id)
  JSON.parse(res.body)['bugs'].first
end

#bug_exists?(bug_id) ⇒ Boolean

Check if bug exists

Parameters:

  • bug_id (Integer)

    id of bug

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/onlyoffice_bugzilla_helper/bug_data.rb', line 25

def bug_exists?(bug_id)
  bug_status(bug_id)
  true
rescue JSON::ParserError, NoMethodError
  false
end

#bug_status(bug_id) ⇒ String

Get status of bug

Parameters:

  • bug_id (String, Integer)

    id of bug

Returns:

  • (String)

    status of bug



17
18
19
20
# File 'lib/onlyoffice_bugzilla_helper/bug_data.rb', line 17

def bug_status(bug_id)
  parsed_json = bug_data(bug_id)
  parsed_json['status']
end

#get_bug_history(bug_id) ⇒ Array

Get history of bug

Parameters:

  • bug_id (Integer)

    id of bug

Returns:

  • (Array)

    history of bug



43
44
45
46
# File 'lib/onlyoffice_bugzilla_helper/bug_data.rb', line 43

def get_bug_history(bug_id)
  result = get_bug_history_result(bug_id)
  JSON.parse(result.body).fetch('bugs', []).first.fetch('history', [])
end

#get_bugs_by_filter(filters) ⇒ Array

Get list of bugs filtered by parameters

Parameters:

  • filters (Hash)

    dictionary of filters (e.g., {‘status’ => ‘NEW’, ‘product’ => “Office” })

Returns:

  • (Array)

    list of bugs



35
36
37
38
# File 'lib/onlyoffice_bugzilla_helper/bug_data.rb', line 35

def get_bugs_by_filter(filters)
  result = get_bugs_result(filters)
  JSON.parse(result.body).fetch('bugs', [])
end