Skip to content

Commit

Permalink
Statistics controller spec: without params done
Browse files Browse the repository at this point in the history
  • Loading branch information
vitoriamr committed Jan 22, 2018
1 parent 621aae2 commit 729f985
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/controllers/manage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def check_statistics_params

def statistics
check_statistics_params
@data = Mconf::StatisticsModule.generate(@from_date, @to_date)
@statistics = Mconf::StatisticsModule.generate(@from_date, @to_date)
end

def statistics_filter
Expand All @@ -118,7 +118,7 @@ def statistics_filter
def statistics_csv
check_statistics_params
respond_to do |format|
format.csv { send_data Mconf::StatisticsModule.generate_csv(@from_date, @to_date), type: Mime::CSV, disposition: "attachment", filename: "overview-from-#{@from_date.strftime('%m/%d/%Y')}-to-#{@to_date.strftime('%m/%d/%Y')}.csv" }
format.csv { send_data Mconf::StatisticsModule.generate_csv(@from_date, @to_date), type: Mime::CSV, disposition: "attachment", filename: "overview-from-#{@from_date.strftime('%m-%d-%Y')}-to-#{@to_date.strftime('%m-%d-%Y')}.csv" }
end
end
end
30 changes: 15 additions & 15 deletions app/views/manage/_statistics_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,48 @@

.resource-filter-without-text
.title= t('.users.title')
.text= t('.users.all', value: @data[:users][:all])
.text= t('.users.approved', value: @data[:users][:approved])
.text= t('.users.not_approved', value: @data[:users][:not_approved])
.text= t('.users.disabled', value: @data[:users][:disabled])
.text= t('.users.all', value: @statistics[:users][:all])
.text= t('.users.approved', value: @statistics[:users][:approved])
.text= t('.users.not_approved', value: @statistics[:users][:not_approved])
.text= t('.users.disabled', value: @statistics[:users][:disabled])

-#.list-container.list-tablefied
.title= t('.spaces.title')
.text= t('.spaces.all', value: @data[:spaces][:all])
.text= t('.spaces.private', value: @data[:spaces][:private])
.text= t('.spaces.public', value: @data[:spaces][:public])
.text= t('.spaces.disabled', value: @data[:spaces][:disabled])
.text= t('.spaces.all', value: @statistics[:spaces][:all])
.text= t('.spaces.private', value: @statistics[:spaces][:private])
.text= t('.spaces.public', value: @statistics[:spaces][:public])
.text= t('.spaces.disabled', value: @statistics[:spaces][:disabled])

-#.list-container.list-tablefied
.title= t('.meetings.title')
.text= t('.meetings.all', value: @data[:meetings][:all])
.text= t('.meetings.all', value: @statistics[:meetings][:all])

- total = @data[:meetings][:total]
- total = @statistics[:meetings][:total]
- if total == 0
.text= t('.meetings.total', value: total)
- else
.text= t('.meetings.total', value: distance_of_time_in_words_to_now(Time.now + total, include_seconds: false))

- average = @data[:meetings][:average]
- average = @statistics[:meetings][:average]
- if average == 0
.text= t('.meetings.average', value: average)
- else
.text= t('.meetings.average', value: distance_of_time_in_words_to_now(Time.now + average, include_seconds: false))

-#.list-container.list-tablefied
.title= t('.recordings.title')
.text= t('.recordings.all', value: @data[:recordings][:all])
.text= t('.recordings.all', value: @statistics[:recordings][:all])

- total = @data[:recordings][:total]
- total = @statistics[:recordings][:total]
- if total == 0
.text= t('.recordings.total', value: total)
- else
.text= t('.recordings.total', value: distance_of_time_in_words_to_now(Time.now + total, include_seconds: false))

- average = @data[:recordings][:average]
- average = @statistics[:recordings][:average]
- if average == 0
.text= t('.recordings.average', value: average)
- else
.text= t('.recordings.average', value: distance_of_time_in_words_to_now(Time.now + average, include_seconds: false))

.text= t('.recordings.size', value: human_file_size(@data[:recordings][:size]))
.text= t('.recordings.size', value: human_file_size(@statistics[:recordings][:size]))
4 changes: 2 additions & 2 deletions lib/mconf/statistics_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module StatisticsModule
def self.total_users(from, to)
result = {}

users = User.where("created_at >= ? AND created_at <= ?", from, to)
users = User.with_disabled.where("created_at >= ? AND created_at <= ?", from, to)

#total users
result[:all] = users.count
Expand All @@ -25,7 +25,7 @@ def self.total_users(from, to)
def self.total_spaces(from, to)
result = {}

spaces = Space.where("created_at >= ? AND created_at <= ?", from, to)
spaces = Space.with_disabled.where("created_at >= ? AND created_at <= ?", from, to)

#total_spaces
result[:all] = spaces.all.count
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/manage_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,9 @@
end

describe "#statistics" do
let(:space) { FactoryGirl.create(:space) }
let(:meeting) { FactoryGirl.create(:bigbluebutton_meeting) }
let(:recording) { FactoryGirl.create(:bigbluebutton_recording) }
let!(:space) { FactoryGirl.create(:space) }
let!(:meeting) { FactoryGirl.create(:bigbluebutton_meeting) }
let!(:recording) { FactoryGirl.create(:bigbluebutton_recording, start_time: 15, end_time: 20) }

context "authorizes" do
let(:user) { FactoryGirl.create(:superuser) }
Expand All @@ -912,11 +912,11 @@
context "with params" do
end


context "without params" do
let(:params) { {} }
let(:data) { {:users=>{:all=>5, :approved=>5, :not_approved=>0, :disabled=>0}, :spaces=>{:all=>1, :private=>1, :public=>0, :disabled=>0}, :meetings=>{:all=>1, :average=>0, :total=>0}, :recordings=>{:all=>1, :size=>0, :average=>5, :total=>5}} }

it { assigns(:statistics).should eql(1) }
it { assigns(:statistics).should eql(data) }
end
end
end
Expand Down

0 comments on commit 729f985

Please sign in to comment.