WIP(teams): add some analytics, remove extraneous logic

This commit is contained in:
Sabe Jones
2021-06-02 15:16:10 -05:00
committed by SabreCat
parent 221dd7a81e
commit d53813adc7
4 changed files with 27 additions and 10 deletions

View File

@@ -1053,10 +1053,6 @@ export default {
}
if (this.isOpenTask) 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;
},

View File

@@ -710,6 +710,16 @@ api.updateTask = {
task: savedTask,
});
}
if (group) {
res.analytics.track('task edit', {
uuid: user._id,
hitType: 'event',
category: 'behavior',
taskType: task.type,
groupID: group._id,
});
}
},
};

View File

@@ -226,6 +226,14 @@ api.assignTask = {
await Promise.all(promises);
res.respond(200, task);
res.analytics.track('task assign', {
uuid: user._id,
hitType: 'event',
category: 'behavior',
taskType: task.type,
groupID: group._id,
});
},
};

View File

@@ -338,19 +338,22 @@ async function scoreTask (user, task, direction, req, res) {
let localTask;
let rollbackUser;
let group;
if (task.group.id) {
group = await Group.getGroup({
user,
groupId: task.group.id,
fields: 'leader managers',
});
}
if (
task.group.id && !task.userId
group && task.group.id && !task.userId
&& direction === 'down'
&& ['todo', 'daily'].includes(task.type)
&& task.completed
&& 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]) {
throw new BadRequest('Cannot uncheck task you did not complete if not a manager.');
}