{"action":"created","issue":{"url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7790","repository_url":"https://api.github.com/repos/HabitRPG/habitrpg","labels_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7790/labels{/name}","comments_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7790/comments","events_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7790/events","html_url":"https://github.com/HabitRPG/habitrpg/issues/7790","id":165792913,"number":7790,"title":"tasksOrder arrays bugs: hide tasks (Dailies can't be completed!), prevent sorting tasks","user":{"login":"Alys","id":1495809,"avatar_url":"https://avatars.githubusercontent.com/u/1495809?v=3","gravatar_id":"","url":"https://api.github.com/users/Alys","html_url":"https://github.com/Alys","followers_url":"https://api.github.com/users/Alys/followers","following_url":"https://api.github.com/users/Alys/following{/other_user}","gists_url":"https://api.github.com/users/Alys/gists{/gist_id}","starred_url":"https://api.github.com/users/Alys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alys/subscriptions","organizations_url":"https://api.github.com/users/Alys/orgs","repos_url":"https://api.github.com/users/Alys/repos","events_url":"https://api.github.com/users/Alys/events{/privacy}","received_events_url":"https://api.github.com/users/Alys/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-15T13:59:45Z","updated_at":"2016-07-15T14:14:17Z","closed_at":null,"body":"Sometimes, the user's `tasksOrder` arrays don't contain all of the user's task IDs, or they contain IDs that shouldn't be there, causing bugs. For example:\r\n\r\n* [ToDo list sort order is not preserved · Issue #7645](https://github.com/HabitRPG/habitrpg/issues/7645) - when IDs for completed To-Dos aren't removed from `tasksOrder.todos` - I've seen several reports of this\r\n* Neilinha (05ccf744-331a-4ae4-8bd9-731ea3413f2e) reported damage at cron for unknown reasons. I  found that 8 of their 15 Dailies didn't have their IDs in `tasksOrder.dailys` and so they weren't showing up in the Dailies list on the website. I replicated this by deleting the IDs of some of my Dailies from my tasksOrder array. This in particular is very damaging since the user can't even tell that the Dailies exist and can't mark them complete or delete them.\r\n\r\nSuggested actions:\r\n- [ ] make sure that the website displays all tasks even if they don't appear in the tasksOrder arrays\r\n- [ ] make sure the mobile apps display all tasks (FYI @viirus) \r\n- [ ] make the Data Display Tool display all tasks (currently it doesn't; Alys will fix)\r\n- AND/OR:\r\n- [ ] **cron does not do damage for any Dailies that are not listed in `tasksOrder.dailys`** - this is an easy partial workaround that could be done quickly to prevent the most damaging effects of this bug\r\n- [ ] cron identifies when tasks aren't in `tasksOrder` and adds them (suggest adding them to the top of the array so the user notices them rapidly)\r\n- [ ] cron identifies when `tasksOrder` contains IDs that should no longer be there and it deletes them\r\n- anything else / instead of these?"},"comment":{"url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/comments/232961836","html_url":"https://github.com/HabitRPG/habitrpg/issues/7790#issuecomment-232961836","issue_url":"https://api.github.com/repos/HabitRPG/habitrpg/issues/7790","id":232961836,"user":{"login":"paglias","id":589911,"avatar_url":"https://avatars.githubusercontent.com/u/589911?v=3","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":"2016-07-15T14:14:17Z","updated_at":"2016-07-15T14:14:17Z","body":"Hmm in theory the client side has code to show unordered tasks too\r\n```\r\n      function syncUserTasks (tasks) {\r\n        user.habits = [];\r\n        user.todos = [];\r\n        user.dailys = [];\r\n        user.rewards = [];\r\n\r\n        // Order tasks based on tasksOrder\r\n        var groupedTasks = _(tasks)\r\n          .groupBy('type')\r\n          .forEach(function (tasksOfType, type) {\r\n            var order = user.tasksOrder[type + 's'];\r\n            var orderedTasks = new Array(tasksOfType.length);\r\n            var unorderedTasks = []; // what we want to add later\r\n\r\n            tasksOfType.forEach(function (task, index) {\r\n              var taskId = task._id;\r\n              var i = order[index] === taskId ? index : order.indexOf(taskId);\r\n              if (i === -1) {\r\n                unorderedTasks.push(task);\r\n              } else {\r\n                orderedTasks[i] = task;\r\n              }\r\n            });\r\n\r\n            // Remove empty values from the array and add any unordered task\r\n            user[type + 's'] = _.compact(orderedTasks).concat(unorderedTasks);\r\n          }).value();\r\n      }\r\n```\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"paglias"}}