Skip to content

Commit

Permalink
start to stats export, but commented out, for publiclab#963
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren committed Dec 16, 2016
1 parent 7984631 commit 85c77ed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def index

@all_notes = nids.uniq.length
@all_contributors = users.uniq.length

#respond_with(nodes) do |format|
# format.html { render 'stats/index' }
# format.csv { render csv: nodes }
# format.json { render json: [@notes_per_week_past_year, @edits_per_week_past_year] }
#end
end

end
7 changes: 7 additions & 0 deletions app/views/stats/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
<h4><%= raw t('notes.stats.wiki_page_edits', :count => DrupalNodeRevision.count(:all)) %></h4>
<p><%= raw t('notes.stats.edits_per_week', :count => @edits_per_week_past_year.round(2)) %></p>

<!--
<p>
<a href="/stats.json?time=<%= @time.to_formatted_s(:long) %>">JSON download</a>,
<a href="/stats.csv?time=<%= @time.to_formatted_s(:long) %>">CSV download</a>,
</p>
-->

</div>

<script type="text/javascript">
Expand Down
13 changes: 13 additions & 0 deletions test/functional/stats_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ class StatsControllerTest < ActionController::TestCase
test "should assign correct value to graph_comments on GET stats" do
Comment.delete_all
Comment.create!({comment: 'blah', timestamp: Time.now() - 1})

get :index

assert_equal assigns(:graph_comments), Comment.comment_weekly_tallies(52, Time.now()).to_a.sort.to_json
assert_response :success
end

test "should load stats range query" do
get :range

assert_response :success
assert_not_nil assigns(:notes)
assert_not_nil assigns(:wikis)
Expand All @@ -21,4 +24,14 @@ class StatsControllerTest < ActionController::TestCase
assert_not_equal 0, assigns(:people)
end

#test "should load stats range query in JSON" do
# get :index, format: :json

# assert_response :success
# json = JSON.parse(@response.body)
# assert_not_nil json['notes']
# assert_not_nil json['wikis']
# assert_not_nil json['people']
#end

end

0 comments on commit 85c77ed

Please sign in to comment.