Skip to content

Commit

Permalink
Handle zero values in adoption rate chart
Browse files Browse the repository at this point in the history
  • Loading branch information
nid90 committed Jan 9, 2025
1 parent 54a7ed2 commit d0c697f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/components/v2/release_monitoring_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def adoption_chart_data
@chart_data ||= parent_release
.release_health_metrics
.group_by_day(:fetched_at, range: range_start..range_end)
.maximum("round(CAST(sessions_in_last_day::float * 100 / total_sessions_in_last_day::float as numeric), 2)")
.maximum("CASE WHEN total_sessions_in_last_day = 0 THEN 0
ELSE round(CAST(sessions_in_last_day::float * 100 / total_sessions_in_last_day::float as numeric), 2)
END")
.compact
.map { |k, v| [k.strftime("%d %b"), {adoption_rate: v, rollout_percentage: store_rollout.rollout_percentage_at(k)}] }
.last(10)
Expand Down

0 comments on commit d0c697f

Please sign in to comment.