Skip to content

Commit 4171348

Browse files
committed
coverage progress chart
1 parent 664f983 commit 4171348

File tree

7 files changed

+27
-2
lines changed

7 files changed

+27
-2
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ gem "turbo-rails" # Hotwire's SPA-like page accelerator [https://turbo.hotwired.
1212
gem "stimulus-rails" # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
1313
gem "tailwindcss-rails" # Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]
1414
gem "sprockets-rails" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
15+
gem "chartkick", "~> 5.1" # Charts
1516

1617
# API
1718
gem "jbuilder" # Build JSON APIs with ease [https://github.com/rails/jbuilder]

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ GEM
109109
rack-test (>= 0.6.3)
110110
regexp_parser (>= 1.5, < 3.0)
111111
xpath (~> 3.2)
112+
chartkick (5.1.2)
112113
concurrent-ruby (1.3.4)
113114
connection_pool (2.4.1)
114115
crass (1.0.6)
@@ -397,6 +398,7 @@ DEPENDENCIES
397398
bootsnap
398399
brakeman
399400
capybara
401+
chartkick (~> 5.1)
400402
debug
401403
devise (~> 4.9)
402404
dotenv-rails (~> 3.1)

app/javascript/application.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
22
import "@hotwired/turbo-rails"
33
import "controllers"
4+
5+
// https://chartkick.com/
6+
import "chartkick"
7+
import "Chart.bundle"

app/models/project.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ def reset_api_auth!
1919
update!(api_auth_digest: Digest::SHA512.hexdigest(token))
2020
token
2121
end
22+
23+
def reports_coverage_progress
24+
reports.map do |report|
25+
next if report.bundled_html.blank?
26+
27+
[report.created_at, report.general_coverage]
28+
end
29+
end
2230
end

app/models/report.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ def simplecov_generate_results
5858
end
5959
end
6060

61+
def general_coverage
62+
results["general_coverage"]
63+
end
64+
6165
def formatted_coverage
62-
return if results["general_coverage"].blank?
66+
return if general_coverage.blank?
6367

64-
"#{results["general_coverage"]}%"
68+
"#{general_coverage}%"
6569
end
6670

6771
private

app/views/projects/show.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<h5>Project</h5>
33
<h1><%= @project.handle %></h1>
44

5+
<%= line_chart @project.reports_coverage_progress %>
6+
57
<div>
68
<ul class="list-disc">
79
<h4>Reports</h4>

config/importmap.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55
pin "@hotwired/stimulus", to: "stimulus.min.js"
66
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
77
pin_all_from "app/javascript/controllers", under: "controllers"
8+
9+
# https://chartkick.com/
10+
pin "chartkick", to: "chartkick.js"
11+
pin "Chart.bundle", to: "Chart.bundle.js"

0 commit comments

Comments
 (0)