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
|
response = make_request
|
||||||
json = parse_json(response)
|
json = parse_json(response)
|
||||||
os_results = select_os(json)
|
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
|
else
|
||||||
'Operating system not found.'
|
'Operating system not found.'
|
||||||
end
|
end
|
||||||
|
@ -102,12 +106,12 @@ class MicrosoftKbChecker
|
||||||
end
|
end
|
||||||
|
|
||||||
def kbs_for_os(os_json)
|
def kbs_for_os(os_json)
|
||||||
supersedence = os_json.values_at('supersedence')
|
supersedence = os_json.dig('supersedence')
|
||||||
articles = article_title_keys(os_json)
|
articles = article_title_keys(os_json)
|
||||||
kbs = articles.map do |article_info|
|
kbs = articles.map do |article_info|
|
||||||
num = article_info[:article_num]
|
num = article_info[:article_num]
|
||||||
os_json.values_at("articleTitle#{num}")
|
os_json.values_at("articleTitle#{num}")
|
||||||
end
|
end.flatten.reject! { |kb| kb == '' }
|
||||||
{
|
{
|
||||||
os_name: os_json['name'],
|
os_name: os_json['name'],
|
||||||
kbs: kbs,
|
kbs: kbs,
|
||||||
|
|
Loading…
Add table
Reference in a new issue