Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Jenkins-status: UNSTABLE #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions jobs/build_health.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SUCCESS = 'Successful'
UNSTABLE = 'Unstable'
FAILED = 'Failed'

def api_functions
Expand Down Expand Up @@ -123,7 +124,7 @@ def get_jenkins_build_health(build)
latest_build = builds_with_status.first
return {
name: latest_build['fullDisplayName'],
status: latest_build['result'] == 'SUCCESS' ? SUCCESS : FAILED,
status: latest_build['result'] == 'SUCCESS' ? SUCCESS : latest_build['result'] == 'UNSTABLE' ? UNSTABLE : FAILED,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find nested ternaries to be very difficult to read. What about something like:

jenkins_statuses = { 'SUCCESS' => SUCCESS, 'UNSTABLE' => UNSTABLE }
# ...
status: jenkins_statuses[latest_build['result']] || FAILED

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments :) make sense.
I'll commit changes later when I have more time or feel free to adjust to your wishes! 👍

duration: latest_build['duration'] / 1000,
link: latest_build['url'],
health: calculate_health(successful_count, builds_with_status.count),
Expand All @@ -135,4 +136,4 @@ def get_jenkins_build_health(build)
Builds::BUILD_LIST.each do |build|
send_event(build['id'], get_build_health(build))
end
end
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like having new lines at the ends of files 😄 Sorry, don't have any linting set up.

4 changes: 3 additions & 1 deletion widgets/build_window/build_window.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class Dashing.BuildWindow extends Dashing.Widget
$(@node).css('background-color', '#a73737')
else if data.status == 'Successful'
$(@node).css('background-color', '#03A06E')
else if data.status == 'Unstable'
$(@node).css('background-color', '#F5B041')

@accessor 'image', ->
health = @get('health')
Expand All @@ -20,4 +22,4 @@ class Dashing.BuildWindow extends Dashing.Widget
else 'assets/health-00to19.svg'

@accessor 'show-health', ->
@get('health') >= 0
@get('health') >= 0