Skip to content

Commit

Permalink
resultのfailedのlimitとoffsetを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
MurakawaTakuya committed Jan 17, 2025
1 parent da56341 commit f999911
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion functions/src/routers/resultRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ const getResults = async (
onlyFinished = false
) => {
let baseQuery = db.collection("goal").limit(limit).offset(offset);
let failedBaseQuery = db.collection("goal").limit(100).offset(0);

if (userId) {
const userDoc = await getUserFromId(userId);
if (!userDoc.exists) {
return res.status(404).json({ message: "User not found" });
}
baseQuery = baseQuery.where("userId", "==", userId);
failedBaseQuery = failedBaseQuery.where("userId", "==", userId);
}

if (onlyPending && onlyFinished) {
Expand Down Expand Up @@ -73,7 +75,7 @@ const getResults = async (
};
}

const failedSnapshot = await baseQuery
const failedSnapshot = await failedBaseQuery
.where("post", "==", null)
.where("deadline", "<=", now)
.where("deadline", ">", earliestSubmittedAt)
Expand Down

0 comments on commit f999911

Please sign in to comment.