mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Ignore (and warn about) achievements with empty queries. Fixed embarrassing bug with more-practice / skip-ahead branching not doing anything for non-admins.
This commit is contained in:
parent
0d68ad250d
commit
a7069e19bd
3 changed files with 6 additions and 4 deletions
|
@ -116,8 +116,8 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
c.readyToRank = @level.get('type', true) is 'hero-ladder' and @session.readyToRank()
|
||||
c.level = @level
|
||||
@continueLevelLink = @getNextLevelLink 'continue'
|
||||
@morePracticeLevelLink = me.isAdmin() and @getNextLevelLink 'more_practice'
|
||||
@skipAheadLevelLink = me.isAdmin() and @getNextLevelLink 'skip_ahead'
|
||||
@morePracticeLevelLink = @getNextLevelLink 'more_practice'
|
||||
@skipAheadLevelLink = @getNextLevelLink 'skip_ahead'
|
||||
c.continueButtons = [
|
||||
{key: 'skip_ahead', link: @skipAheadLevelLink, 'choice-explicit': 'skip', 'choice-implicit': 'too_easy'}
|
||||
{key: 'continue', link: @continueLevelLink, 'choice-explicit': 'next_level', 'choice-implicit': 'just_right'}
|
||||
|
|
|
@ -23,12 +23,12 @@ class EarnedAchievementHandler extends Handler
|
|||
ids = req.query.achievementIDs
|
||||
if (not ids) or (ids.length is 0)
|
||||
return @sendBadInputError(res, 'For a get-by-achievement-ids request, need to provide ids.')
|
||||
|
||||
|
||||
ids = ids.split(',')
|
||||
for id in ids
|
||||
if not Handler.isID(id)
|
||||
return @sendBadInputError(res, "Not a MongoDB ObjectId: #{id}")
|
||||
|
||||
|
||||
query.achievement = {$in: ids}
|
||||
EarnedAchievement.find query, (err, earnedAchievements) ->
|
||||
return @sendDatabaseError(res, err) if err
|
||||
|
@ -121,6 +121,7 @@ class EarnedAchievementHandler extends Handler
|
|||
return doneWithAchievement new Error "Model with collection '#{achievement.get 'collection'}' doesn't exist." unless model?
|
||||
|
||||
finalQuery = _.clone achievement.get 'query'
|
||||
return doneWithAchievement() if _.isEmpty finalQuery
|
||||
finalQuery.$or = [{}, {}] # Allow both ObjectIDs or hex string IDs
|
||||
finalQuery.$or[0][achievement.userField] = userID
|
||||
finalQuery.$or[1][achievement.userField] = mongoose.Types.ObjectId userID
|
||||
|
|
|
@ -36,6 +36,7 @@ AchievablePlugin = (schema, options) ->
|
|||
for achievement in loadedAchievements[category]
|
||||
do (achievement) ->
|
||||
query = achievement.get('query')
|
||||
return log.warn("Empty achievement query for #{achievement.get('name')}.") if _.isEmpty query
|
||||
isRepeatable = achievement.get('proportionalTo')?
|
||||
alreadyAchieved = if isNew then false else LocalMongo.matchesQuery originalDocObj, query
|
||||
newlyAchieved = LocalMongo.matchesQuery(docObj, query)
|
||||
|
|
Loading…
Reference in a new issue