apiv2 more of previous (task xform)

This commit is contained in:
Tyler Renelle
2013-08-04 16:24:30 -04:00
parent 746153f417
commit 63ab1b1975
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
"expect.js": "~0.2.0",
"derby-i18n": "git://github.com/switz/derby-i18n#master",
"relative-date": "~1.1.1",
"lodash": "~1.2.1",
"lodash": "~1.3.1",
"async": "~0.2.9",
"optimist": "~0.5.2"
},
+1 -1
View File
@@ -36,7 +36,7 @@ router.post '/', api.auth, (req, res, next) ->
uObj = misc.hydrate user.get()
#transform user structure FROM user.tasks{} + user.habitIds[] TO user.habits[] + user.todos[] etc.
_.each ['habit','daily','todo','reward'], (type) ->
uObj["#{type}s"] = _.transform uObj["#{type}Ids"], (result, tid) -> uObj.tasks[tid]
uObj["#{type}s"] = _.transform uObj["#{type}Ids"], (result, tid) -> result.push(uObj.tasks[tid])
delete uObj["#{type}Ids"]
delete uObj.tasks
res.json 200, uObj