{"action":"created","issue":{"url":"https://api.github.com/repos/HabitRPG/habitica/issues/9595","repository_url":"https://api.github.com/repos/HabitRPG/habitica","labels_url":"https://api.github.com/repos/HabitRPG/habitica/issues/9595/labels{/name}","comments_url":"https://api.github.com/repos/HabitRPG/habitica/issues/9595/comments","events_url":"https://api.github.com/repos/HabitRPG/habitica/issues/9595/events","html_url":"https://github.com/HabitRPG/habitica/pull/9595","id":277611812,"number":9595,"title":"Allow Masterclasser achievement when quests completed out of order","user":{"login":"AlyxMoon","id":8443638,"avatar_url":"https://avatars2.githubusercontent.com/u/8443638?v=4","gravatar_id":"","url":"https://api.github.com/users/AlyxMoon","html_url":"https://github.com/AlyxMoon","followers_url":"https://api.github.com/users/AlyxMoon/followers","following_url":"https://api.github.com/users/AlyxMoon/following{/other_user}","gists_url":"https://api.github.com/users/AlyxMoon/gists{/gist_id}","starred_url":"https://api.github.com/users/AlyxMoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlyxMoon/subscriptions","organizations_url":"https://api.github.com/users/AlyxMoon/orgs","repos_url":"https://api.github.com/users/AlyxMoon/repos","events_url":"https://api.github.com/users/AlyxMoon/events{/privacy}","received_events_url":"https://api.github.com/users/AlyxMoon/received_events","type":"User","site_admin":false},"labels":[{"id":192741463,"url":"https://api.github.com/repos/HabitRPG/habitica/labels/status:%20pr:%20ready%20for%20review","name":"status: pr: ready for review","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-11-29T02:51:32Z","updated_at":"2017-12-04T10:20:59Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/HabitRPG/habitica/pulls/9595","html_url":"https://github.com/HabitRPG/habitica/pull/9595","diff_url":"https://github.com/HabitRPG/habitica/pull/9595.diff","patch_url":"https://github.com/HabitRPG/habitica/pull/9595.patch"},"body":"Fixes #9461\r\n\r\n### Changes\r\n[//]: # (Describe the changes that were made in detail here. Include pictures if necessary)\r\nUpdated file `website\\server\\models\\group.js`\r\n- Changed the check that current completed quest is the final in Master Classer series, it now checks that the completed quest is any in the series\r\n- Updated query to include last Master Classer quest\r\n\r\nUpdated test file `test\\api\\v3\\unit\\models\\group.test.js`\r\n- Added a new test to check whether Master Classer achievement is given when the final quest to be completed is not the final one in the series\r\n- Updated test for Master Classer achievement (existing test and new test for when completed out of order) to include an `exec()` call after `findById()`\r\n\r\n----\r\nUUID: cc212fcc-5f96-403b-a785-17ba66c7b11a\r\n"},"comment":{"url":"https://api.github.com/repos/HabitRPG/habitica/issues/comments/348919732","html_url":"https://github.com/HabitRPG/habitica/pull/9595#issuecomment-348919732","issue_url":"https://api.github.com/repos/HabitRPG/habitica/issues/9595","id":348919732,"user":{"login":"paglias","id":589911,"avatar_url":"https://avatars2.githubusercontent.com/u/589911?v=4","gravatar_id":"","url":"https://api.github.com/users/paglias","html_url":"https://github.com/paglias","followers_url":"https://api.github.com/users/paglias/followers","following_url":"https://api.github.com/users/paglias/following{/other_user}","gists_url":"https://api.github.com/users/paglias/gists{/gist_id}","starred_url":"https://api.github.com/users/paglias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paglias/subscriptions","organizations_url":"https://api.github.com/users/paglias/orgs","repos_url":"https://api.github.com/users/paglias/repos","events_url":"https://api.github.com/users/paglias/events{/privacy}","received_events_url":"https://api.github.com/users/paglias/received_events","type":"User","site_admin":false},"created_at":"2017-12-04T10:20:59Z","updated_at":"2017-12-04T10:20:59Z","author_association":"CONTRIBUTOR","body":"@AlyxMoon I think it might be worth to try changing this code in website/server/models/group.js\r\n\r\n```\r\nasync function _updateUserWithRetries (userId, updates, numTry = 1, query = {}) {\r\n  query._id = userId;\r\n  return await User.update(query, updates).exec()\r\n    .then((raw) => {\r\n      return raw;\r\n    }).catch((err) => {\r\n      if (numTry < MAX_UPDATE_RETRIES) {\r\n        return _updateUserWithRetries(userId, updates, ++numTry);\r\n      } else {\r\n        throw err;\r\n      }\r\n    });\r\n}\r\n```\r\n\r\nto something like this\r\n\r\n```\r\nasync function _updateUserWithRetries (userId, updates, numTry = 1, query = {}) {\r\n  query._id = userId;\r\n  try {\r\n    return await User.update(query, updates).exec();\r\n  } catch (err) {\r\n    if (numTry < MAX_UPDATE_RETRIES) {\r\n      return _updateUserWithRetries(userId, updates, ++numTry);\r\n    } else {\r\n      throw err;\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nto see if there was a concurrency problem."}}
{"actor":{"display_login":"paglias"}}