lib/dri/commands/fetch/failures.rb in dri-0.3.1 vs lib/dri/commands/fetch/failures.rb in dri-0.4.0
- old
+ new
@@ -38,32 +38,31 @@
logger.info "Fetching today's failures..."
spinner.run do # rubocop:disable Metrics/BlockLength
response = api_client.fetch_failures(date: @today_iso_format, state: 'opened')
- if response.nil?
+ if response.empty?
logger.info 'Life is great, there are no new failures today!'
exit 0
end
response.each do |failure|
- title = failure['title'].truncate(60)
- author = failure['author']['username']
- url = failure['web_url']
- award_emoji_url = failure['_links']['award_emoji']
+ title = failure.title.truncate(60)
+ author = failure.to_h.dig('author', 'username')
+ url = failure.web_url
triaged = add_color('x', :red)
- emoji_awards = api_client.fetch_awarded_emojis(award_emoji_url).find do |e|
- (e['name'] == emoji) && (e['user']['username'] == username)
+ emoji_awards = api_client.fetch_awarded_emojis(failure.iid).find do |e|
+ e.name == emoji && e.to_h.dig('user', 'username') == username
end
if emoji_awards
triaged = add_color('✓', :green)
triaged_counter += 1
end
if @options[:urgent]
- labels = failure['labels']
+ labels = failure.labels
labels.each do |label|
if label.include?('found:canary.gitlab.com' && 'found:canary.staging.gitlab.com')
urgent << [title, triaged, author, url]
end