add some adjument around filtering out response when given OS is not found in response data
This commit is contained in:
parent
84ac80289a
commit
0d7cf0761d
1 changed files with 7 additions and 3 deletions
|
@ -89,7 +89,11 @@ class MicrosoftKbChecker
|
|||
response = make_request
|
||||
json = parse_json(response)
|
||||
os_results = select_os(json)
|
||||
kbs_for_os(os_results) if os_results
|
||||
if os_results.nil?
|
||||
'Product not found in response data.'
|
||||
else
|
||||
kbs_for_os(os_results)
|
||||
end
|
||||
else
|
||||
'Operating system not found.'
|
||||
end
|
||||
|
@ -102,12 +106,12 @@ class MicrosoftKbChecker
|
|||
end
|
||||
|
||||
def kbs_for_os(os_json)
|
||||
supersedence = os_json.values_at('supersedence')
|
||||
supersedence = os_json.dig('supersedence')
|
||||
articles = article_title_keys(os_json)
|
||||
kbs = articles.map do |article_info|
|
||||
num = article_info[:article_num]
|
||||
os_json.values_at("articleTitle#{num}")
|
||||
end
|
||||
end.flatten.reject! { |kb| kb == '' }
|
||||
{
|
||||
os_name: os_json['name'],
|
||||
kbs: kbs,
|
||||
|
|
Loading…
Add table
Reference in a new issue