tango-app-api-analysis-zone 3.0.0-alpha.25 → 3.0.0-alpha.27

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-analysis-zone",
3
- "version": "3.0.0-alpha.25",
3
+ "version": "3.0.0-alpha.27",
4
4
  "description": "zone Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -162,6 +162,22 @@ export const zoneConcentrationSummaryTableV1 = async ( req, res ) => {
162
162
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
163
163
  if ( resultData ) {
164
164
  if ( resultData.status_code == '200' ) {
165
+ if ( reqestData.export ) {
166
+ if ( resultData.zoneConcentrationData.length>0 ) {
167
+ const exportdata = [];
168
+ resultData.zoneConcentrationData.forEach( ( element ) => {
169
+ exportdata.push( {
170
+ 'Zone Name': element.zoneName,
171
+ 'Footfall(Actuals)': element.footfallCount,
172
+ 'DwellTime(Average)': element.avgDwellTime,
173
+ 'Concentration': element.concentrationRate,
174
+ } );
175
+ } );
176
+ return await download( exportdata, res );
177
+ } else {
178
+ return res.sendError( 'No Content', 204 );
179
+ }
180
+ }
165
181
  return res.sendSuccess( resultData );
166
182
  } else {
167
183
  return res.sendError( 'No Content', 204 );
@@ -178,6 +194,26 @@ export const zoneConcentrationSummaryTableV1 = async ( req, res ) => {
178
194
  export const zoneHeatmapAvailableDatesV1 = async ( req, res ) => {
179
195
  try {
180
196
  let reqestData = req.body;
197
+
198
+ const date1 = new Date( reqestData.fromDate );
199
+ const date2 = new Date( reqestData.toDate );
200
+ // Get the difference in milliseconds
201
+ const diffInMs = date2 - date1;
202
+ // Convert milliseconds to days
203
+ let diffInDays = parseInt( diffInMs / ( 1000 * 60 * 60 * 24 ) );
204
+ if ( diffInDays <= 7 ) {
205
+ if ( reqestData.dateType == 'weekly' ) {
206
+ // subtract 7 days to the date
207
+ date2.setDate( date2.getDate() - 7 );
208
+ reqestData.fromDate = date2.toISOString().slice( 0, 10 );
209
+ }
210
+ if ( reqestData.dateType == 'monthly' ) {
211
+ // subtract 31 days to the date
212
+ date2.setDate( date2.getDate() - 31 );
213
+ reqestData.fromDate = date2.toISOString().slice( 0, 10 );
214
+ }
215
+ }
216
+
181
217
  let LamdaURL = 'https://tgtkai5zzq7fhp7ymtsnm3a2lm0czulr.lambda-url.ap-south-1.on.aws/';
182
218
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
183
219
  if ( resultData ) {
@@ -57,6 +57,7 @@ export const validateZoneConcentrationSummaryTableSchema = joi.object( {
57
57
  search: joi.string().optional().allow( '' ),
58
58
  sortBy: joi.number().optional().allow( '' ),
59
59
  sort: joi.string().optional().allow( '' ),
60
+ export: joi.boolean().required(),
60
61
  } );
61
62
 
62
63
  export const validateZoneConcentrationSummaryTableParams = {