forked from consuldemocracy/consuldemocracy
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from AyuntamientoMadrid/stats
Improves performance of stats dashboard
- Loading branch information
Showing
13 changed files
with
121 additions
and
76 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
module StatsHelper | ||
|
||
def events_chart_tag(events, opt={}) | ||
def event_chart_tag(events, opt={}) | ||
events = events.join(',') if events.is_a? Array | ||
opt[:data] ||= {} | ||
opt[:data][:graph] = admin_api_stats_path(events: events) | ||
content_tag :div, "", opt | ||
end | ||
|
||
def visits_chart_tag(opt={}) | ||
events = events.join(',') if events.is_a? Array | ||
def chart_tag(opt={}) | ||
opt[:data] ||= {} | ||
opt[:data][:graph] = admin_api_stats_path(visits: true) | ||
opt[:data][:graph] = admin_api_stats_path(chart_data(opt)) | ||
content_tag :div, "", opt | ||
end | ||
|
||
def spending_proposals_chart_tag(opt={}) | ||
events = events.join(',') if events.is_a? Array | ||
opt[:data] ||= {} | ||
opt[:data][:graph] = admin_api_stats_path(spending_proposals: true) | ||
content_tag :div, "", opt | ||
def chart_data(opt={}) | ||
data = nil | ||
if opt[:id].present? | ||
data = {opt[:id] => true} | ||
elsif opt[:event].present? | ||
data = {event: opt[:event]} | ||
end | ||
data | ||
end | ||
|
||
def graph_link_text(event) | ||
text = t("admin.stats.graph.#{event}") | ||
if text.to_s.match(/translation missing/) | ||
text = event | ||
end | ||
text | ||
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= render '/shared/back_link' %> | ||
|
||
<div id="graph" class="small-12 column"> | ||
<h2><%= t "admin.stats.graph.#{name || event}" %> (<%= count %>)</h2> | ||
<%= chart_tag id: name, event: event %> | ||
</div> |
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,5 @@ | ||
<% content_for :head do %> | ||
<%= javascript_include_tag "stat_graphs", 'data-turbolinks-track' => true %> | ||
<% end %> | ||
<%= render 'graph', name: @name, event: @event, count: @count %> |
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 |
---|---|---|
|
@@ -8,4 +8,8 @@ def track_event(name, properties, options) | |
event.ip = request.ip | ||
end | ||
end | ||
|
||
def exclude? | ||
false | ||
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
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