Skip to content

Commit

Permalink
Spaces, meetings and recordings with filters
Browse files Browse the repository at this point in the history
  • Loading branch information
vitoriamr committed Jan 17, 2018
1 parent ec6294f commit 19337b4
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions lib/mconf/statistics_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module StatisticsModule
def self.total_users(from, to)
result = {}

puts from
puts to

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

#total users
Expand All @@ -27,30 +24,34 @@ def self.total_users(from, to)
def self.total_spaces(from, to)
result = {}

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

#total_spaces
result[:all] = Space.all.count
result[:all] = spaces.all.count

# private spaces
result[:private] = Space.where(public: false).count
result[:private] = spaces.where(public: false).count

# public spaces
result[:public] = Space.where(public: true).count
result[:public] = spaces.where(public: true).count

# disabled spaces
result[:disabled] = Space.where(disabled: true).count
result[:disabled] = spaces.where(disabled: true).count

result
end

def self.total_meetings(from, to)
result = {}

meetings = BigbluebuttonMeeting.where("created_at >= ? AND created_at < ?", from, to)

total = 0
duration = 0
average = 0
count = 0

BigbluebuttonMeeting.find_each do |m|
meetings.find_each do |m|
# total duration
unless m.finish_time == nil
duration = m.finish_time - m.create_time
Expand All @@ -61,7 +62,11 @@ def self.total_meetings(from, to)

# duration average
result[:all] = count
result[:average] = total / count
if count == 0
result[:average] = 0
else
result[:average] = total / count
end
result[:total] = total

result
Expand All @@ -70,12 +75,14 @@ def self.total_meetings(from, to)
def self.total_recordings(from, to)
result = {}

recordings = BigbluebuttonRecording.where("created_at >= ? AND created_at < ?", from, to)

total = 0
duration = 0
average = 0
count = 0

BigbluebuttonRecording.find_each do |r|
recordings.find_each do |r|
# total duration
duration = r.end_time - r.start_time
total = total + duration
Expand All @@ -84,7 +91,11 @@ def self.total_recordings(from, to)

# duration average
result[:all] = count
result[:average] = total / count
if count == 0
result[:average] = 0
else
result[:average] = total / count
end
result[:total] = total

result
Expand Down

0 comments on commit 19337b4

Please sign in to comment.