New statistics: lastLogin, lastMessageSentAt, lastSeenSubscription, migration, version, branch and tag

pull/1523/head
Marcelo Schmidt 10 years ago
parent e87095558c
commit adad9cca89
  1. 7
      packages/rocketchat-lib/server/models/Messages.coffee
  2. 12
      packages/rocketchat-lib/server/models/Subscriptions.coffee
  3. 6
      packages/rocketchat-lib/server/models/Users.coffee
  4. 13
      packages/rocketchat-statistics/server/functions/get.coffee

@ -101,6 +101,13 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base
return @find query, options
getLastTimestamp: (options = {}) ->
query = { ts: { $exists: 1 } }
options.sort = { ts: -1 }
options.limit = 1
return @find(query, options)?.fetch?()?[0]?.ts
cloneAndSaveAsHistoryById: (_id) ->
me = RocketChat.models.Users.findOneById Meteor.userId()
record = @findOneById _id

@ -25,6 +25,12 @@ RocketChat.models.Subscriptions = new class extends RocketChat.models._Base
return @find query, options
getLastSeen: (options = {}) ->
query = { ls: { $exists: 1 } }
options.sort = { ls: -1 }
options.limit = 1
return @find(query, options)?.fetch?()?[0]?.ls
# UPDATE
archiveByRoomIdAndUserId: (roomId, userId) ->
@ -195,11 +201,11 @@ RocketChat.models.Subscriptions = new class extends RocketChat.models._Base
return @update query, update, { multi: true }
updateTypeByRoomId: (roomId, type) ->
query =
query =
rid: roomId
update =
$set:
$set:
t: type
return @update query, update, { multi: true }

@ -99,6 +99,12 @@ RocketChat.models.Users = new class extends RocketChat.models._Base
return @find query, options
getLastLogin: (options = {}) ->
query = { lastLogin: { $exists: 1 } }
options.sort = { lastLogin: -1 }
options.limit = 1
return @find(query, options)?.fetch?()?[0]?.lastLogin
# UPDATE
updateLastLoginById: (_id) ->

@ -3,8 +3,9 @@ RocketChat.statistics.get = ->
# Version
statistics.uniqueId = RocketChat.settings.get("uniqueID")
statistics.version = BuildInfo?.commit?.hash
statistics.versionDate = BuildInfo?.commit?.date
statistics.version = RocketChat.Info?.version
statistics.tag = RocketChat.Info?.tag
statistics.branch = RocketChat.Info?.branch
# User statistics
statistics.totalUsers = Meteor.users.find().count()
@ -70,6 +71,14 @@ RocketChat.statistics.get = ->
else
console.log 'private group user statistic not found'.red
statistics.lastLogin = RocketChat.models.Users.getLastLogin()
statistics.lastMessageSentAt = RocketChat.models.Messages.getLastTimestamp()
statistics.lastSeenSubscription = RocketChat.models.Subscriptions.getLastSeen()
migration = Migrations?._getControl()
if migration
statistics.migration = _.pick(migration, 'version', 'locked')
os = Npm.require('os')
statistics.os =
type: os.type()

Loading…
Cancel
Save