MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / buildRangeProgressQuery

Function buildRangeProgressQuery

utils/progresses.js:213–227  ·  view source on GitHub ↗
(queryParams)

Source from the content-addressed store, hash-verified

211 * @throws {Error} If neither userId nor taskId is provided in the queryParams object.
212 */
213const buildRangeProgressQuery = (queryParams) => {
214 const { userId, taskId, startDate, endDate } = queryParams;
215 let query = progressesCollection;
216 if (userId) {
217 query = query.where("type", "==", "user").where("userId", "==", userId);
218 } else if (taskId) {
219 query = query.where("type", "==", "task").where("taskId", "==", taskId);
220 } else {
221 throw new Error("Either userId or taskId is required.");
222 }
223 const startDateTimestamp = Date.parse(startDate);
224 const endDateTimestamp = Date.parse(endDate);
225 query = query.where("date", ">=", startDateTimestamp).where("date", "<=", endDateTimestamp);
226 return query;
227};
228/**
229 * Retrieves progress records for a given date range.
230 * @param {QuerySnapshot} query - A reference to the query for fetching progress documents.

Callers 1

getRangeProgressDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected