@@ -2,12 +2,7 @@ const { Conflict, NotFound } = require("http-errors");
2
2
const fireStore = require ( "../utils/firestore" ) ;
3
3
const trackedProgressesCollection = fireStore . collection ( "trackedProgresses" ) ;
4
4
const { assertUserOrTaskExists } = require ( "../utils/progresses" ) ;
5
- const {
6
- buildTrackedProgressQueryByType,
7
- buildQueryForFetchingDocsOfType,
8
- getTrackedProgressDocs,
9
- buildQueryToFetchTrackedDoc,
10
- } = require ( "../utils/monitor" ) ;
5
+ const { buildQueryByTypeId, buildQueryForFetchingDocsOfType, getTrackedProgressDocs } = require ( "../utils/monitor" ) ;
11
6
const { RESPONSE_MESSAGES } = require ( "../constants/monitor" ) ;
12
7
const { RESOURCE_NOT_FOUND , RESOURCE_ALREADY_TRACKED } = RESPONSE_MESSAGES ;
13
8
@@ -27,7 +22,7 @@ const { RESOURCE_NOT_FOUND, RESOURCE_ALREADY_TRACKED } = RESPONSE_MESSAGES;
27
22
const createTrackedProgressDocument = async ( documentData ) => {
28
23
const { userId, taskId } = documentData ;
29
24
await assertUserOrTaskExists ( { userId, taskId } ) ;
30
- const query = buildTrackedProgressQueryByType ( { userId, taskId } ) ;
25
+ const query = buildQueryByTypeId ( { userId, taskId } ) ;
31
26
const existingDocumentSnapshot = await query . get ( ) ;
32
27
if ( ! existingDocumentSnapshot . empty ) {
33
28
throw new Conflict ( RESOURCE_ALREADY_TRACKED ) ;
@@ -59,7 +54,7 @@ const createTrackedProgressDocument = async (documentData) => {
59
54
const updateTrackedProgressDocument = async ( req ) => {
60
55
const { type, typeId } = req . params ;
61
56
const updatedData = { type, [ `${ type } Id` ] : typeId } ;
62
- const query = buildTrackedProgressQueryByType ( updatedData ) ;
57
+ const query = buildQueryByTypeId ( updatedData ) ;
63
58
const existingDocumentSnapshot = await query . get ( ) ;
64
59
if ( existingDocumentSnapshot . empty ) {
65
60
throw new NotFound ( RESOURCE_NOT_FOUND ) ;
@@ -85,7 +80,7 @@ const getTrackedProgressDocuments = async (reqQuery) => {
85
80
const { userId, taskId } = reqQuery ;
86
81
if ( userId || taskId ) {
87
82
await assertUserOrTaskExists ( { userId, taskId } ) ;
88
- query = buildQueryToFetchTrackedDoc ( reqQuery ) ;
83
+ query = buildQueryByTypeId ( reqQuery ) ;
89
84
docsData = ( await getTrackedProgressDocs ( query ) ) [ 0 ] ;
90
85
} else {
91
86
query = buildQueryForFetchingDocsOfType ( reqQuery ) ;
0 commit comments