mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-14 10:12:21 +00:00
fix(challenge export): do not fetch users and tasks concurrently
This commit is contained in:
parent
6e9ab1dbbb
commit
4d88787ba0
1 changed files with 13 additions and 12 deletions
|
|
@ -591,21 +591,22 @@ api.exportChallengeCsv = {
|
|||
// computation on MongoDB but then iterated through all
|
||||
// results on the server so the perf difference isn't that big (hopefully)
|
||||
|
||||
const [members, tasks] = await Promise.all([
|
||||
User.find({ challenges: challengeId })
|
||||
.select(nameFields)
|
||||
.sort({ _id: 1 })
|
||||
.lean() // so we don't involve mongoose
|
||||
.exec(),
|
||||
const members = await User
|
||||
.find({ challenges: challengeId })
|
||||
.select(nameFields)
|
||||
.sort({ _id: 1 })
|
||||
.lean() // so we don't involve mongoose
|
||||
.exec();
|
||||
|
||||
Tasks.Task.find({
|
||||
const tasks = Tasks.Task
|
||||
.find({
|
||||
'challenge.id': challengeId,
|
||||
userId: { $exists: true },
|
||||
}).sort({ userId: 1, text: 1 })
|
||||
.select('userId type text value notes streak')
|
||||
.lean()
|
||||
.exec(),
|
||||
]);
|
||||
})
|
||||
.sort({ userId: 1, text: 1 })
|
||||
.select('userId type text value notes streak')
|
||||
.lean() // so we don't involve mongoose
|
||||
.exec();
|
||||
|
||||
let resArray = members
|
||||
.map(member => [member._id, member.profile.name, member.auth.local.username]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue