mirror of
https://github.com/wassname/talk.git
synced 2026-07-14 11:18:50 +08:00
Returning actions, items, and comments as seperate arrays.
This commit is contained in:
+2
-1
@@ -47,9 +47,10 @@ ActionSchema.statics.getActionSummaries = function(item_ids) {
|
||||
const actionSummaries = rawActions.reduce((actionObj, action) => {
|
||||
if (!actionObj[action.item_id]) {
|
||||
actionObj[action.item_id] = {
|
||||
id: action.id,
|
||||
type: action.action_type,
|
||||
count: 1,
|
||||
current_user: false //Corrent this later when we have authentication
|
||||
current_user: false //Update this later when we have authentication
|
||||
};
|
||||
} else {
|
||||
actionObj[action.item_id].count ++;
|
||||
|
||||
@@ -17,7 +17,11 @@ router.get('/', (req, res, next) => {
|
||||
Action.getActionSummaries(comments.map((comment) => comment.id))
|
||||
]);
|
||||
}).then(([comments, users, actions]) => {
|
||||
res.json([...comments, ...users, ...actions]);
|
||||
res.json({
|
||||
comments,
|
||||
users,
|
||||
actions
|
||||
});
|
||||
}).catch(error => {
|
||||
next(error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user