mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 07:38:20 -05:00
Refactor handlers to /server/handlers
This commit is contained in:
parent
c3e5416166
commit
29cd880480
44 changed files with 77 additions and 77 deletions
|
@ -17,7 +17,7 @@ do (setupLodash = this) ->
|
|||
|
||||
database.connect()
|
||||
|
||||
UserHandler = require '../server/users/user_handler'
|
||||
UserHandler = require '../server/handlers/user_handler'
|
||||
User = require '../server/models/User'
|
||||
|
||||
startDate = new Date 2015, 11, 1
|
||||
|
|
|
@ -12,7 +12,7 @@ do (setupLodash = this) ->
|
|||
|
||||
database.connect()
|
||||
|
||||
EarnedAchievementHandler = require '../server/achievements/earned_achievement_handler'
|
||||
EarnedAchievementHandler = require '../server/handlers/earned_achievement_handler'
|
||||
log.info 'Starting earned achievement recalculation...'
|
||||
EarnedAchievementHandler.constructor.recalculate (err) ->
|
||||
log.error err if err?
|
||||
|
|
|
@ -14,7 +14,7 @@ database.connect()
|
|||
|
||||
User = require '../server/models/User'
|
||||
Payment = require '../server/models/Payment'
|
||||
PaymentHandler = require '../server/payments/payment_handler'
|
||||
PaymentHandler = require '../server/handlers/payment_handler'
|
||||
|
||||
t0 = new Date().getTime()
|
||||
total = 100000
|
||||
|
|
|
@ -12,7 +12,7 @@ do (setupLodash = this) ->
|
|||
database.connect()
|
||||
|
||||
### USER STATS ###
|
||||
UserHandler = require '../server/users/user_handler'
|
||||
UserHandler = require '../server/handlers/user_handler'
|
||||
|
||||
report = (func, name, done) ->
|
||||
log.info 'Started ' + name + '...'
|
||||
|
|
|
@ -14,7 +14,7 @@ do (setupLodash = this) ->
|
|||
|
||||
database.connect()
|
||||
|
||||
UserHandler = require '../server/users/user_handler'
|
||||
UserHandler = require '../server/handlers/user_handler'
|
||||
User = require '../server/models/User'
|
||||
|
||||
userIDs = [
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
module.exports.handlers =
|
||||
'analytics_log_event': 'analytics/analytics_log_event_handler'
|
||||
'analytics_perday': 'analytics/analytics_perday_handler'
|
||||
'analytics_string': 'analytics/analytics_string_handler'
|
||||
'analytics_stripe_invoice': 'analytics/analytics_stripe_invoice_handler'
|
||||
'analytics_log_event': 'handlers/analytics_log_event_handler'
|
||||
'analytics_perday': 'handlers/analytics_perday_handler'
|
||||
'analytics_string': 'handlers/analytics_string_handler'
|
||||
'analytics_stripe_invoice': 'handlers/analytics_stripe_invoice_handler'
|
||||
# TODO: Disabling this until we know why our app servers CPU grows out of control.
|
||||
# 'analytics_users_active': 'analytics/analytics_users_active_handler'
|
||||
'article': 'articles/article_handler'
|
||||
'campaign': 'campaigns/campaign_handler'
|
||||
'clan': 'clans/clan_handler'
|
||||
'classroom': 'classrooms/classroom_handler'
|
||||
'course': 'courses/course_handler'
|
||||
'course_instance': 'courses/course_instance_handler'
|
||||
'level': 'levels/level_handler'
|
||||
'level_component': 'levels/components/level_component_handler'
|
||||
'level_feedback': 'levels/feedbacks/level_feedback_handler'
|
||||
'level_session': 'levels/sessions/level_session_handler'
|
||||
'level_system': 'levels/systems/level_system_handler'
|
||||
'patch': 'patches/patch_handler'
|
||||
'payment': 'payments/payment_handler'
|
||||
'purchase': 'purchases/purchase_handler'
|
||||
'thang_type': 'levels/thangs/thang_type_handler'
|
||||
'user': 'users/user_handler'
|
||||
'user_code_problem': 'user_code_problems/user_code_problem_handler'
|
||||
'user_remark': 'users/remarks/user_remark_handler'
|
||||
'mail_sent': 'mail/sent/mail_sent_handler'
|
||||
'achievement': 'achievements/achievement_handler'
|
||||
'earned_achievement': 'achievements/earned_achievement_handler'
|
||||
'poll': 'polls/poll_handler'
|
||||
'prepaid': 'prepaids/prepaid_handler'
|
||||
'subscription': 'payments/subscription_handler'
|
||||
'user_polls_record': 'polls/user_polls_record_handler'
|
||||
# 'analytics_users_active': 'handlers/analytics_users_active_handler'
|
||||
'article': 'handlers/article_handler'
|
||||
'campaign': 'handlers/campaign_handler'
|
||||
'clan': 'handlers/clan_handler'
|
||||
'classroom': 'handlers/classroom_handler'
|
||||
'course': 'handlers/course_handler'
|
||||
'course_instance': 'handlers/course_instance_handler'
|
||||
'level': 'handlers/level_handler'
|
||||
'level_component': 'handlers/level_component_handler'
|
||||
'level_feedback': 'handlers/level_feedback_handler'
|
||||
'level_session': 'handlers/level_session_handler'
|
||||
'level_system': 'handlers/level_system_handler'
|
||||
'patch': 'handlers/patch_handler'
|
||||
'payment': 'handlers/payment_handler'
|
||||
'purchase': 'handlers/purchase_handler'
|
||||
'thang_type': 'handlers/thang_type_handler'
|
||||
'user': 'handlers/user_handler'
|
||||
'user_code_problem': 'handlers/user_code_problem_handler'
|
||||
'user_remark': 'handlers/user_remark_handler'
|
||||
'mail_sent': 'handlers/mail_sent_handler'
|
||||
'achievement': 'handlers/achievement_handler'
|
||||
'earned_achievement': 'handlers/earned_achievement_handler'
|
||||
'poll': 'handlers/poll_handler'
|
||||
'prepaid': 'handlers/prepaid_handler'
|
||||
'subscription': 'handlers/subscription_handler'
|
||||
'user_polls_record': 'handlers/user_polls_record_handler'
|
||||
|
||||
module.exports.handlerUrlOverrides =
|
||||
'analytics_log_event': 'analytics.log.event'
|
||||
|
|
|
@ -4,11 +4,11 @@ Handler = require '../commons/Handler'
|
|||
AnalyticsLogEvent = require '../models/AnalyticsLogEvent'
|
||||
Clan = require './../models/Clan'
|
||||
EarnedAchievement = require '../models/EarnedAchievement'
|
||||
EarnedAchievementHandler = require '../achievements/earned_achievement_handler'
|
||||
EarnedAchievementHandler = require './earned_achievement_handler'
|
||||
LevelSession = require '../models/LevelSession'
|
||||
LevelSessionHandler = require '../levels/sessions/level_session_handler'
|
||||
LevelSessionHandler = require './level_session_handler'
|
||||
User = require '../models/User'
|
||||
UserHandler = require '../users/user_handler'
|
||||
UserHandler = require './user_handler'
|
||||
|
||||
memberLimit = 200
|
||||
|
|
@ -5,7 +5,7 @@ Classroom = require './../models/Classroom'
|
|||
User = require '../models/User'
|
||||
sendwithus = require '../sendwithus'
|
||||
utils = require '../lib/utils'
|
||||
UserHandler = require '../users/user_handler'
|
||||
UserHandler = require './user_handler'
|
||||
|
||||
ClassroomHandler = class ClassroomHandler extends Handler
|
||||
modelClass: Classroom
|
|
@ -5,11 +5,11 @@ Classroom = require '../models/Classroom'
|
|||
Course = require '../models/Course'
|
||||
CourseInstance = require './../models/CourseInstance'
|
||||
LevelSession = require '../models/LevelSession'
|
||||
LevelSessionHandler = require '../levels/sessions/level_session_handler'
|
||||
LevelSessionHandler = require './level_session_handler'
|
||||
Prepaid = require '../models/Prepaid'
|
||||
PrepaidHandler = require '../prepaids/prepaid_handler'
|
||||
PrepaidHandler = require './prepaid_handler'
|
||||
User = require '../models/User'
|
||||
UserHandler = require '../users/user_handler'
|
||||
UserHandler = require './user_handler'
|
||||
utils = require '../../app/core/utils'
|
||||
{objectIdFromTimestamp} = require '../lib/utils'
|
||||
sendwithus = require '../sendwithus'
|
|
@ -1,10 +1,10 @@
|
|||
LevelComponent = require './../../models/LevelComponent'
|
||||
Handler = require '../../commons/Handler'
|
||||
LevelComponent = require './../models/LevelComponent'
|
||||
Handler = require '../commons/Handler'
|
||||
mongoose = require 'mongoose'
|
||||
|
||||
LevelComponentHandler = class LevelComponentHandler extends Handler
|
||||
modelClass: LevelComponent
|
||||
jsonSchema: require '../../../app/schemas/models/level_component'
|
||||
jsonSchema: require '../../app/schemas/models/level_component'
|
||||
editableProperties: [
|
||||
'system'
|
||||
'description'
|
|
@ -1,10 +1,10 @@
|
|||
LevelFeedback = require './../../models/LevelFeedback'
|
||||
Handler = require '../../commons/Handler'
|
||||
LevelFeedback = require './../models/LevelFeedback'
|
||||
Handler = require '../commons/Handler'
|
||||
|
||||
class LevelFeedbackHandler extends Handler
|
||||
modelClass: LevelFeedback
|
||||
editableProperties: ['rating', 'review', 'level', 'levelID', 'levelName']
|
||||
jsonSchema: require '../../../app/schemas/models/level_feedback'
|
||||
jsonSchema: require '../../app/schemas/models/level_feedback'
|
||||
|
||||
makeNewInstance: (req) ->
|
||||
feedback = super(req)
|
|
@ -1,7 +1,7 @@
|
|||
Level = require './../models/Level'
|
||||
Session = require './../models/LevelSession'
|
||||
User = require '../models/User'
|
||||
SessionHandler = require './sessions/level_session_handler'
|
||||
SessionHandler = require './level_session_handler'
|
||||
Feedback = require './../models/LevelFeedback'
|
||||
Handler = require '../commons/Handler'
|
||||
mongoose = require 'mongoose'
|
|
@ -1,5 +1,5 @@
|
|||
LevelSession = require './../../models/LevelSession'
|
||||
Handler = require '../../commons/Handler'
|
||||
LevelSession = require './../models/LevelSession'
|
||||
Handler = require '../commons/Handler'
|
||||
log = require 'winston'
|
||||
|
||||
TIMEOUT = 1000 * 30 # no activity for 30 seconds means it's not active
|
|
@ -1,5 +1,5 @@
|
|||
LevelSystem = require './../../models/LevelSystem'
|
||||
Handler = require '../../commons/Handler'
|
||||
LevelSystem = require './../models/LevelSystem'
|
||||
Handler = require '../commons/Handler'
|
||||
|
||||
LevelSystemHandler = class LevelSystemHandler extends Handler
|
||||
modelClass: LevelSystem
|
||||
|
@ -13,7 +13,7 @@ LevelSystemHandler = class LevelSystemHandler extends Handler
|
|||
'configSchema'
|
||||
]
|
||||
postEditableProperties: ['name']
|
||||
jsonSchema: require '../../../app/schemas/models/level_system'
|
||||
jsonSchema: require '../../app/schemas/models/level_system'
|
||||
|
||||
getEditableProperties: (req, document) ->
|
||||
props = super(req, document)
|
|
@ -1,10 +1,10 @@
|
|||
MailSent = require './../../models/MailSent'
|
||||
Handler = require '../../commons/Handler'
|
||||
MailSent = require './../models/MailSent'
|
||||
Handler = require '../commons/Handler'
|
||||
|
||||
class MailSentHandler extends Handler
|
||||
modelClass: MailSent
|
||||
editableProperties: ['mailTask','user','sent']
|
||||
jsonSchema: require '../../../app/schemas/models/mail_sent'
|
||||
jsonSchema: require '../../app/schemas/models/mail_sent'
|
||||
|
||||
hasAccess: (req) ->
|
||||
req.user?.isAdmin()
|
|
@ -1,9 +1,9 @@
|
|||
ThangType = require './../../models/ThangType'
|
||||
Handler = require '../../commons/Handler'
|
||||
ThangType = require './../models/ThangType'
|
||||
Handler = require '../commons/Handler'
|
||||
|
||||
ThangTypeHandler = class ThangTypeHandler extends Handler
|
||||
modelClass: ThangType
|
||||
jsonSchema: require '../../../app/schemas/models/thang_type'
|
||||
jsonSchema: require '../../app/schemas/models/thang_type'
|
||||
editableProperties: [
|
||||
'name'
|
||||
'raw'
|
|
@ -13,12 +13,12 @@ AnalyticsLogEvent = require '../models/AnalyticsLogEvent'
|
|||
Clan = require '../models/Clan'
|
||||
CourseInstance = require '../models/CourseInstance'
|
||||
LevelSession = require '../models/LevelSession'
|
||||
LevelSessionHandler = require '../levels/sessions/level_session_handler'
|
||||
LevelSessionHandler = require './level_session_handler'
|
||||
Payment = require '../models/Payment'
|
||||
SubscriptionHandler = require '../payments/subscription_handler'
|
||||
DiscountHandler = require '../payments/discount_handler'
|
||||
SubscriptionHandler = require './subscription_handler'
|
||||
DiscountHandler = require './discount_handler'
|
||||
EarnedAchievement = require '../models/EarnedAchievement'
|
||||
UserRemark = require './remarks/UserRemark'
|
||||
UserRemark = require './../models/UserRemark'
|
||||
{findStripeSubscription} = require '../lib/utils'
|
||||
{isID} = require '../lib/utils'
|
||||
slack = require '../slack'
|
|
@ -1,10 +1,10 @@
|
|||
UserRemark = require './UserRemark'
|
||||
Handler = require '../../commons/Handler'
|
||||
UserRemark = require './../models/UserRemark'
|
||||
Handler = require '../commons/Handler'
|
||||
|
||||
class UserRemarkHandler extends Handler
|
||||
modelClass: UserRemark
|
||||
editableProperties: ['user', 'contact', 'history', 'tasks', 'userName', 'contactName']
|
||||
jsonSchema: require '../../../app/schemas/models/user_remark'
|
||||
jsonSchema: require '../../app/schemas/models/user_remark'
|
||||
|
||||
hasAccess: (req) ->
|
||||
req.user?.isAdmin()
|
|
@ -1,6 +1,6 @@
|
|||
log = require 'winston'
|
||||
Payment = require '../models/Payment'
|
||||
PaymentHandler = require '../payments/payment_handler'
|
||||
PaymentHandler = require '../handlers/payment_handler'
|
||||
|
||||
module.exports =
|
||||
logError: (user, msg) ->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mongoose = require 'mongoose'
|
||||
plugins = require '../../plugins/plugins'
|
||||
jsonschema = require '../../../app/schemas/models/user_remark'
|
||||
plugins = require '../plugins/plugins'
|
||||
jsonschema = require '../../app/schemas/models/user_remark'
|
||||
|
||||
UserRemarkSchema = new mongoose.Schema({
|
||||
created:
|
|
@ -1,7 +1,7 @@
|
|||
authentication = require 'passport'
|
||||
LocalStrategy = require('passport-local').Strategy
|
||||
User = require '../models/User'
|
||||
UserHandler = require '../users/user_handler'
|
||||
UserHandler = require '../handlers/user_handler'
|
||||
LevelSession = require '../models/LevelSession'
|
||||
config = require '../../server_config'
|
||||
errors = require '../commons/errors'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mail = require '../commons/mail'
|
||||
MailSent = require '../models/MailSent'
|
||||
UserRemark = require '../users/remarks/UserRemark'
|
||||
UserRemark = require '../models/UserRemark'
|
||||
User = require '../models/User'
|
||||
async = require 'async'
|
||||
errors = require '../commons/errors'
|
||||
|
|
|
@ -10,12 +10,12 @@ geoip = require 'geoip-lite'
|
|||
database = require './server/commons/database'
|
||||
perfmon = require './server/commons/perfmon'
|
||||
baseRoute = require './server/routes/base'
|
||||
user = require './server/users/user_handler'
|
||||
user = require './server/handlers/user_handler'
|
||||
logging = require './server/commons/logging'
|
||||
config = require './server_config'
|
||||
auth = require './server/routes/auth'
|
||||
routes = require './server/routes'
|
||||
UserHandler = require './server/users/user_handler'
|
||||
UserHandler = require './server/handlers/user_handler'
|
||||
slack = require './server/slack'
|
||||
Mandate = require './server/models/Mandate'
|
||||
global.tv4 = require 'tv4' # required for TreemaUtils to work
|
||||
|
|
|
@ -223,7 +223,7 @@ describe 'Achieving Achievements', ->
|
|||
|
||||
|
||||
describe 'Recalculate Achievements', ->
|
||||
EarnedAchievementHandler = require '../../../server/achievements/earned_achievement_handler'
|
||||
EarnedAchievementHandler = require '../../../server/handlers/earned_achievement_handler'
|
||||
|
||||
it 'remove earned achievements', (done) ->
|
||||
f = ->
|
||||
|
|
|
@ -6,7 +6,7 @@ request = require '../request'
|
|||
|
||||
describe '/db/patch', ->
|
||||
async = require 'async'
|
||||
UserHandler = require '../../../server/users/user_handler'
|
||||
UserHandler = require '../../../server/handlers/user_handler'
|
||||
|
||||
it 'clears the db first', (done) ->
|
||||
clearModels [User, Article, Patch], (err) ->
|
||||
|
|
|
@ -371,7 +371,7 @@ describe 'Statistics', ->
|
|||
LevelComponent = require '../../../server/models/LevelComponent'
|
||||
ThangType = require '../../../server/models/ThangType'
|
||||
User = require '../../../server/models/User'
|
||||
UserHandler = require '../../../server/users/user_handler'
|
||||
UserHandler = require '../../../server/handlers/user_handler'
|
||||
|
||||
it 'keeps track of games completed', (done) ->
|
||||
session = new LevelSession
|
||||
|
|
Loading…
Reference in a new issue