Skip to content
Snippets Groups Projects
Commit fa26d744 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Replace all Statistics

parent b4024e64
No related branches found
No related tags found
No related merge requests found
......@@ -24,8 +24,8 @@ Package.onUse(function(api) {
// Statistics
api.addFiles('lib/rocketchat.coffee', [ 'client', 'server' ]);
api.addFiles([
'server/models/Statistics.coffee',
'server/models/MRStatistics.coffee',
'server/collections/Statistics.coffee',
'server/functions/get.coffee',
'server/functions/save.coffee',
'server/methods/getStatistics.coffee'
......
@Statistics = new Meteor.Collection 'rocketchat_statistics'
......@@ -53,6 +53,6 @@ RocketChat.statistics.getAverage = ->
out.os.loadavg = [ (v.os.loadavg[0] / v.count), (v.os.loadavg[1] / v.count), (v.os.loadavg[2] / v.count) ]
return out
result = Statistics.mapReduce(m, r, { finalize: f, out: "rocketchat_mr_statistics" })
result = RocketChat.models.Statistics.model.mapReduce(m, r, { finalize: f, out: "rocketchat_mr_statistics" })
statistics = RocketChat.models.MRStatistics.find().fetch()
return statistics
RocketChat.statistics.save = ->
statistics = RocketChat.statistics.get()
statistics.createdAt = new Date
Statistics.insert statistics
RocketChat.models.Statistics.insert statistics
return statistics
RocketChat.models.Statistics = new class asd extends RocketChat.models._Base
constructor: ->
@_initModel 'statistics'
# FIND ONE
findOneById: (_id, options) ->
query =
_id: _id
return @findOne query, options
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment