mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Added streak to export of challenge tasks (#9625)
* Added streak to export of challenge tasks * Fixed tests
This commit is contained in:
@@ -64,11 +64,11 @@ describe('GET /challenges/:challengeId/export/csv', () => {
|
||||
let sortedMembers = _.sortBy([members[0], members[1], members[2], groupLeader], '_id');
|
||||
let splitRes = res.split('\n');
|
||||
|
||||
expect(splitRes[0]).to.equal('UUID,name,Task,Value,Notes,Task,Value,Notes');
|
||||
expect(splitRes[1]).to.equal(`${sortedMembers[0]._id},${sortedMembers[0].profile.name},habit:Task 1,0,,todo:Task 2,0,`);
|
||||
expect(splitRes[2]).to.equal(`${sortedMembers[1]._id},${sortedMembers[1].profile.name},habit:Task 1,0,,todo:Task 2,0,`);
|
||||
expect(splitRes[3]).to.equal(`${sortedMembers[2]._id},${sortedMembers[2].profile.name},habit:Task 1,0,,todo:Task 2,0,`);
|
||||
expect(splitRes[4]).to.equal(`${sortedMembers[3]._id},${sortedMembers[3].profile.name},habit:Task 1,0,,todo:Task 2,0,`);
|
||||
expect(splitRes[0]).to.equal('UUID,name,Task,Value,Notes,Streak,Task,Value,Notes,Streak');
|
||||
expect(splitRes[1]).to.equal(`${sortedMembers[0]._id},${sortedMembers[0].profile.name},habit:Task 1,0,,0,todo:Task 2,0,,0`);
|
||||
expect(splitRes[2]).to.equal(`${sortedMembers[1]._id},${sortedMembers[1].profile.name},habit:Task 1,0,,0,todo:Task 2,0,,0`);
|
||||
expect(splitRes[3]).to.equal(`${sortedMembers[2]._id},${sortedMembers[2].profile.name},habit:Task 1,0,,0,todo:Task 2,0,,0`);
|
||||
expect(splitRes[4]).to.equal(`${sortedMembers[3]._id},${sortedMembers[3].profile.name},habit:Task 1,0,,0,todo:Task 2,0,,0`);
|
||||
expect(splitRes[5]).to.equal('');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -555,7 +555,7 @@ api.exportChallengeCsv = {
|
||||
'challenge.id': challengeId,
|
||||
userId: {$exists: true},
|
||||
}).sort({userId: 1, text: 1})
|
||||
.select('userId type text value notes')
|
||||
.select('userId type text value notes streak')
|
||||
.lean().exec(),
|
||||
]);
|
||||
|
||||
@@ -570,7 +570,9 @@ api.exportChallengeCsv = {
|
||||
index++;
|
||||
}
|
||||
|
||||
resArray[index].push(`${task.type}:${task.text}`, task.value, task.notes);
|
||||
const streak = task.streak || 0;
|
||||
|
||||
resArray[index].push(`${task.type}:${task.text}`, task.value, task.notes, streak);
|
||||
});
|
||||
|
||||
// The first row is going to be UUID name Task Value Notes repeated n times for the n challenge tasks
|
||||
@@ -578,7 +580,7 @@ api.exportChallengeCsv = {
|
||||
return result.concat(array);
|
||||
}, []).sort();
|
||||
resArray.unshift(['UUID', 'name']);
|
||||
_.times(challengeTasks.length, () => resArray[0].push('Task', 'Value', 'Notes'));
|
||||
_.times(challengeTasks.length, () => resArray[0].push('Task', 'Value', 'Notes', 'Streak'));
|
||||
|
||||
res.set({
|
||||
'Content-Type': 'text/csv',
|
||||
|
||||
Reference in New Issue
Block a user