mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
WIP(teams): add some analytics, remove extraneous logic
This commit is contained in:
@@ -1053,10 +1053,6 @@ export default {
|
|||||||
}
|
}
|
||||||
if (this.isOpenTask) return false;
|
if (this.isOpenTask) return false;
|
||||||
if (this.task.group.assignedUsers.indexOf(this.user._id) !== -1) return false;
|
if (this.task.group.assignedUsers.indexOf(this.user._id) !== -1) return false;
|
||||||
if (
|
|
||||||
this.task.group.assignedUsers.length > 0
|
|
||||||
&& this.task.group.assignedUsers.indexOf(this.user._id) === -1
|
|
||||||
) return true;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -710,6 +710,16 @@ api.updateTask = {
|
|||||||
task: savedTask,
|
task: savedTask,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (group) {
|
||||||
|
res.analytics.track('task edit', {
|
||||||
|
uuid: user._id,
|
||||||
|
hitType: 'event',
|
||||||
|
category: 'behavior',
|
||||||
|
taskType: task.type,
|
||||||
|
groupID: group._id,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -226,6 +226,14 @@ api.assignTask = {
|
|||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|
||||||
res.respond(200, task);
|
res.respond(200, task);
|
||||||
|
|
||||||
|
res.analytics.track('task assign', {
|
||||||
|
uuid: user._id,
|
||||||
|
hitType: 'event',
|
||||||
|
category: 'behavior',
|
||||||
|
taskType: task.type,
|
||||||
|
groupID: group._id,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -338,19 +338,22 @@ async function scoreTask (user, task, direction, req, res) {
|
|||||||
|
|
||||||
let localTask;
|
let localTask;
|
||||||
let rollbackUser;
|
let rollbackUser;
|
||||||
|
let group;
|
||||||
|
|
||||||
|
if (task.group.id) {
|
||||||
|
group = await Group.getGroup({
|
||||||
|
user,
|
||||||
|
groupId: task.group.id,
|
||||||
|
fields: 'leader managers',
|
||||||
|
});
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
task.group.id && !task.userId
|
group && task.group.id && !task.userId
|
||||||
&& direction === 'down'
|
&& direction === 'down'
|
||||||
&& ['todo', 'daily'].includes(task.type)
|
&& ['todo', 'daily'].includes(task.type)
|
||||||
&& task.completed
|
&& task.completed
|
||||||
&& task.group.completedBy !== user._id
|
&& task.group.completedBy !== user._id
|
||||||
) {
|
) {
|
||||||
const group = await Group.getGroup({
|
|
||||||
user,
|
|
||||||
groupId: task.group.id,
|
|
||||||
fields: 'leader managers',
|
|
||||||
});
|
|
||||||
if (group.leader !== user._id && !group.managers[user._id]) {
|
if (group.leader !== user._id && !group.managers[user._id]) {
|
||||||
throw new BadRequest('Cannot uncheck task you did not complete if not a manager.');
|
throw new BadRequest('Cannot uncheck task you did not complete if not a manager.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user