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

Function buildQueryToFetchDocs

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

Source from the content-addressed store, hash-verified

103 * @returns {Query} A Firestore query object that filters progress documents based on the given parameters.
104 */
105const buildQueryToFetchDocs = (queryParams) => {
106 const { type, userId, taskId, orderBy } = queryParams;
107 const orderByField = PROGRESS_VALID_SORT_FIELDS[0];
108 const isAscOrDsc = orderBy && PROGRESS_VALID_SORT_FIELDS[0] === orderBy ? "asc" : "desc";
109
110 if (type) {
111 return progressesCollection.where("type", "==", type).orderBy(orderByField, isAscOrDsc);
112 } else if (userId) {
113 return progressesCollection
114 .where("type", "==", "user")
115 .where("userId", "==", userId)
116 .orderBy(orderByField, isAscOrDsc);
117 } else {
118 return progressesCollection
119 .where("type", "==", "task")
120 .where("taskId", "==", taskId)
121 .orderBy(orderByField, isAscOrDsc);
122 }
123};
124
125/**
126 * Builds a Firestore query to retrieve a paginated list of progress documents within a date range,

Callers 1

getProgressDocumentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected