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
Sparklines with ajax and rubocop clean #1315
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c148e64
Sparklines!
danielbeardsley bfc3ea1
Sparklines: translate "Graph" in table header
danielbeardsley 66bcc30
do sparklines work in a separate ajax call. fix rubocop issues
burnettk 20abe21
remove test code. really nice code review catch
burnettk d948cf0
mongo aggregation for performance. helper to lib. methods for readabi…
burnettk be94ee4
trying to pacify coveralls
burnettk 60ee335
remove now-unused method
burnettk File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
= now = Time.current | ||
%tr | ||
- two_week_percentages = problem.grouped_notice_count_relative_percentages((now - 13.days).at_beginning_of_day) | ||
- twenty_four_hour_percentages = problem.grouped_notice_count_relative_percentages((now - 23.hours).at_beginning_of_hour) | ||
%th= t('.graph-2-weeks') | ||
%td= Sparklines.for_relative_percentages(two_week_percentages) | ||
%tr | ||
%th= t('.graph (24 hours)') | ||
%td= Sparklines.for_relative_percentages(twenty_four_hour_percentages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
end | ||
|
||
member do | ||
get :xhr_sparkline | ||
put :resolve | ||
put :unresolve | ||
post :create_issue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Sparklines | ||
class << self | ||
def for_relative_percentages(array_of_relative_percentages) | ||
bars = array_of_relative_percentages.map do |percent| | ||
"<i style='height:#{percent}%'></i>" | ||
end.join | ||
"<div class='spark'>#{bars}</div>".html_safe | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,17 @@ | |
end | ||
end | ||
|
||
describe "GET /apps/:app_id/problems/:id/xhr_sparkline" do | ||
before do | ||
sign_in user | ||
end | ||
|
||
it "renders without error" do | ||
get :xhr_sparkline, app_id: app.id, id: err.problem.id | ||
expect(response).to be_success | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we're going to need something a little more robust in terms of testing here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a bunch of tests for the underlying data in problems_spec. |
||
end | ||
end | ||
|
||
describe "PUT /apps/:app_id/problems/:id/resolve" do | ||
before do | ||
sign_in user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
describe Sparklines do | ||
it 'includes each percentage and adds a percent sign' do | ||
percentages = [33, 75, 100] | ||
sparklines_html = Sparklines.for_relative_percentages(percentages) | ||
percentages.each do |percentage| | ||
expect(sparklines_html).to include("#{percentage}%") | ||
end | ||
end | ||
|
||
it 'has the right number of i tags' do | ||
percentages = [75, 100] | ||
sparklines_html = Sparklines.for_relative_percentages(percentages) | ||
number_of_i_tags = sparklines_html.scan(/<i/).size | ||
expect(number_of_i_tags).to eq(2) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question. Should this action go in the "API"? Any opinions on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like keeping this out of the API so folks don't confuse it for something that they might call from a script or something. it returns html, and it's built just for this rails ajaxy integration. i'm not recommending this necessarily, but one day, if the app were rewritten in reactjs, many of the existing controller actions would return json instead of html, and we could make this one fit that model as well.