tango-app-api-task 1.0.0-beta.2 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-task",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Task",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"mongodb": "^6.10.0",
|
|
25
25
|
"nodemon": "^3.1.7",
|
|
26
26
|
"npm": "^10.9.2",
|
|
27
|
-
"tango-api-schema": "
|
|
28
|
-
"tango-app-api-middleware": "
|
|
27
|
+
"tango-api-schema": "2.2.2",
|
|
28
|
+
"tango-app-api-middleware": "3.1.43-alpha.10",
|
|
29
29
|
"winston": "^3.17.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
31
31
|
},
|
|
@@ -827,21 +827,54 @@ export async function insertSingleProcessData( checklistId ) {
|
|
|
827
827
|
}
|
|
828
828
|
insertdata.questionAnswers = collectSections;
|
|
829
829
|
insertdata.updatedAt = new Date();
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
830
|
+
function getDaysBeforeEndDate( endDate ) {
|
|
831
|
+
const end = dayjs.utc( endDate );
|
|
832
|
+
const now = dayjs.utc();
|
|
833
|
+
|
|
834
|
+
if ( end.isBefore( now ) ) {
|
|
835
|
+
throw new Error( 'End date must be in the future.' );
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
const daysArray = [];
|
|
839
|
+
let currentDate = now.startOf( 'day' );
|
|
840
|
+
|
|
841
|
+
while ( currentDate.isBefore( end ) ) {
|
|
842
|
+
daysArray.push( currentDate.format( ) );
|
|
843
|
+
currentDate = currentDate.add( 1, 'day' );
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
return daysArray;
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
const dateArray = getDaysBeforeEndDate( endDate );
|
|
850
|
+
|
|
851
|
+
for ( const dateVal of dateArray ) {
|
|
852
|
+
const insertdataquery = {
|
|
853
|
+
date_string: dayjs( dateVal ).format( 'YYYY-MM-DD' ),
|
|
854
|
+
date_iso: dayjs( dateVal ).toDate(),
|
|
855
|
+
client_id: insertdata.client_id,
|
|
856
|
+
sourceCheckList_id: insertdata.sourceCheckList_id,
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
const insertDataPerDay = {
|
|
860
|
+
...insertdata,
|
|
861
|
+
date_string: dayjs( dateVal ).format( 'YYYY-MM-DD' ),
|
|
862
|
+
date_iso: dayjs( dateVal ).toDate(),
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
let updatedchecklist;
|
|
866
|
+
let checklistDetails = await taskProcessedConfigService.findOne( insertdataquery );
|
|
867
|
+
|
|
868
|
+
if ( !checklistDetails ) {
|
|
869
|
+
updatedchecklist = await taskProcessedConfigService.insert( insertDataPerDay );
|
|
870
|
+
} else {
|
|
871
|
+
await taskProcessedConfigService.updateOne( { _id: checklistDetails._id }, insertDataPerDay );
|
|
872
|
+
updatedchecklist = checklistDetails;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
if ( updatedchecklist ) {
|
|
876
|
+
await insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, dateVal, startTimeIso, endTimeIso, insertdata );
|
|
877
|
+
}
|
|
845
878
|
}
|
|
846
879
|
}
|
|
847
880
|
}
|
|
@@ -852,7 +885,7 @@ export async function insertSingleProcessData( checklistId ) {
|
|
|
852
885
|
}
|
|
853
886
|
};
|
|
854
887
|
|
|
855
|
-
async function insertPCBulkV3( getCLconfig, checklistId,
|
|
888
|
+
async function insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, date, startTimeIso, endTimeIso, insertdata ) {
|
|
856
889
|
let getquestionQuery = [];
|
|
857
890
|
getquestionQuery.push( {
|
|
858
891
|
$match: {
|
|
@@ -893,7 +926,7 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
893
926
|
element4.checkListName = getCLconfig.checkListName;
|
|
894
927
|
element4.checkListDescription = getCLconfig.checkListDescription;
|
|
895
928
|
element4.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
|
|
896
|
-
element4.date_string = dayjs(
|
|
929
|
+
element4.date_string = dayjs( date ).format( 'YYYY-MM-DD' );
|
|
897
930
|
element4.allowedOverTime = false;
|
|
898
931
|
element4.allowedStoreLocation = getCLconfig.allowedStoreLocation;
|
|
899
932
|
element4.scheduleStartTime = '12:00 AM';
|