tango-app-api-client 3.0.27-dev → 3.0.29-dev
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-client",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.29-dev",
|
|
4
4
|
"description": "client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"mongodb": "^6.3.0",
|
|
26
26
|
"nodemon": "^3.0.3",
|
|
27
27
|
"swagger-ui-express": "^5.0.0",
|
|
28
|
-
"tango-api-schema": "^2.0.
|
|
28
|
+
"tango-api-schema": "^2.0.82",
|
|
29
29
|
"tango-app-api-middleware": "^1.0.54-dev",
|
|
30
30
|
"winston": "^3.11.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -812,9 +812,20 @@ export async function clientList( req, res ) {
|
|
|
812
812
|
}
|
|
813
813
|
|
|
814
814
|
if ( inputData.sortColumName ) {
|
|
815
|
-
clientQuery.push(
|
|
816
|
-
|
|
817
|
-
|
|
815
|
+
clientQuery.push(
|
|
816
|
+
{
|
|
817
|
+
$addFields: {
|
|
818
|
+
lowerCaseSortField: { $toLower: `$${inputData.sortColumName}` },
|
|
819
|
+
},
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
$sort: { lowerCaseSortField: inputData.sortBy || -1 },
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
$project: {
|
|
826
|
+
lowerCaseSortField: 0,
|
|
827
|
+
},
|
|
828
|
+
} );
|
|
818
829
|
}
|
|
819
830
|
if ( inputData.isExport ) {
|
|
820
831
|
clientQuery.push( {
|
|
@@ -954,7 +965,6 @@ export async function clientList( req, res ) {
|
|
|
954
965
|
},
|
|
955
966
|
},
|
|
956
967
|
];
|
|
957
|
-
|
|
958
968
|
const activeStoreCount = await aggregateStore( storeQuery );
|
|
959
969
|
const activeCameraCount = await aggregateCamera( cameraQuery );
|
|
960
970
|
const result = _.values(
|
|
@@ -964,6 +974,19 @@ export async function clientList( req, res ) {
|
|
|
964
974
|
_.keyBy( activeCameraCount, 'clientId' ),
|
|
965
975
|
),
|
|
966
976
|
);
|
|
977
|
+
|
|
978
|
+
let sortedResult = _.sortBy( result, [ ( obj ) => new Date( obj.createdAt ) ] ).reverse();
|
|
979
|
+
if ( inputData.sortColumName ) {
|
|
980
|
+
if ( inputData.sortBy === 1 ) {
|
|
981
|
+
sortedResult = _.sortBy( result, [ ( obj ) => obj[inputData.sortColumName ? inputData.sortColumName : 'clientName']?.toLowerCase() ] );
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
if ( inputData.sortBy === -1 ) {
|
|
985
|
+
sortedResult.reverse();
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
|
|
967
990
|
if ( inputData.isExport ) {
|
|
968
991
|
const resultChunk = await chunkArray( result, 10 );
|
|
969
992
|
const promises = resultChunk.map( async ( chunk ) => {
|
|
@@ -986,7 +1009,7 @@ export async function clientList( req, res ) {
|
|
|
986
1009
|
await download( exportResult, res );
|
|
987
1010
|
return;
|
|
988
1011
|
}
|
|
989
|
-
return res.sendSuccess( { result:
|
|
1012
|
+
return res.sendSuccess( { result: sortedResult, count: clientCount.length } );
|
|
990
1013
|
} catch ( error ) {
|
|
991
1014
|
logger.error( { error: error, function: 'clientList' } );
|
|
992
1015
|
return res.sendError( error, 500 );
|