2014-07-23 09:22:53 -04:00
|
|
|
database = require '../server/commons/database'
|
|
|
|
mongoose = require 'mongoose'
|
|
|
|
log = require 'winston'
|
|
|
|
async = require 'async'
|
|
|
|
|
|
|
|
### SET UP ###
|
|
|
|
do (setupLodash = this) ->
|
|
|
|
GLOBAL._ = require 'lodash'
|
|
|
|
_.str = require 'underscore.string'
|
|
|
|
_.mixin _.str.exports()
|
|
|
|
|
|
|
|
database.connect()
|
|
|
|
|
|
|
|
### USER STATS ###
|
2016-04-07 12:40:53 -04:00
|
|
|
UserHandler = require '../server/handlers/user_handler'
|
2014-07-23 09:22:53 -04:00
|
|
|
|
|
|
|
report = (func, name, done) ->
|
|
|
|
log.info 'Started ' + name + '...'
|
|
|
|
func name, (err) ->
|
|
|
|
log.warn err if err?
|
|
|
|
log.info 'Finished ' + name
|
|
|
|
done err if done?
|
|
|
|
|
|
|
|
whenAllFinished = ->
|
|
|
|
log.info 'All recalculations finished.'
|
|
|
|
process.exit()
|
|
|
|
|
2014-07-24 13:42:43 -04:00
|
|
|
async.parallel [
|
2014-07-23 14:00:28 -04:00
|
|
|
# Misc
|
2015-02-21 17:22:43 -05:00
|
|
|
(c) -> report UserHandler.recalculateStats, 'gamesCompleted', c
|
2015-02-17 23:51:22 -05:00
|
|
|
|
2014-07-23 14:00:28 -04:00
|
|
|
# Edits
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'articleEdits', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelEdits', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelComponentEdits', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelSystemEdits', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'thangTypeEdits', c
|
2015-02-17 23:51:22 -05:00
|
|
|
|
2014-07-24 08:41:06 -04:00
|
|
|
# Patches
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'patchesContributed', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'patchesSubmitted', c
|
2015-02-17 23:51:22 -05:00
|
|
|
|
2014-08-14 19:40:35 -04:00
|
|
|
# Patches in memory
|
2014-07-24 13:42:43 -04:00
|
|
|
(c) -> report UserHandler.recalculateStats, 'totalTranslationPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'totalMiscPatches', c
|
|
|
|
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'articleMiscPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelMiscPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelComponentMiscPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelSystemMiscPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'thangTypeMiscPatches', c
|
|
|
|
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'articleTranslationPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelTranslationPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelComponentTranslationPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'levelSystemTranslationPatches', c
|
|
|
|
(c) -> report UserHandler.recalculateStats, 'thangTypeTranslationPatches', c
|
2014-07-23 09:22:53 -04:00
|
|
|
], whenAllFinished
|