tango-app-api-audio-analytics 1.0.12 → 1.0.13
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
|
@@ -26,6 +26,7 @@ export async function createCohort( req, res ) {
|
|
|
26
26
|
cohortName: inputData.cohortName,
|
|
27
27
|
cohortDescription: inputData.cohortDescription,
|
|
28
28
|
metrics,
|
|
29
|
+
isDeleted: false,
|
|
29
30
|
createdAt: new Date().toISOString(),
|
|
30
31
|
updatedAt: new Date().toISOString(),
|
|
31
32
|
};
|
|
@@ -132,6 +133,32 @@ export async function updateCohort( req, res ) {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
export async function deleteCohort( req, res ) {
|
|
137
|
+
try {
|
|
138
|
+
const { cohortId } = req.body;
|
|
139
|
+
|
|
140
|
+
const updatePayload = {
|
|
141
|
+
doc: {
|
|
142
|
+
isDeleted: true,
|
|
143
|
+
updatedAt: new Date().toISOString(),
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const result = await updateOpenSearchData( 'tango-audio-config', cohortId, updatePayload );
|
|
148
|
+
logger.info( { result } );
|
|
149
|
+
|
|
150
|
+
if ( result && result.body && result.body.result === 'updated' ) {
|
|
151
|
+
return res.sendSuccess( { result: 'Cohort deleted successfully', cohortId } );
|
|
152
|
+
} else {
|
|
153
|
+
return res.sendError( 'Failed to delete cohort', 500 );
|
|
154
|
+
}
|
|
155
|
+
} catch ( error ) {
|
|
156
|
+
const err = error.message || 'Internal Server Error';
|
|
157
|
+
logger.error( { error, message: req.body, function: 'deleteCohort' } );
|
|
158
|
+
return res.sendError( err, 500 );
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
135
162
|
export async function getCohort( req, res ) {
|
|
136
163
|
try {
|
|
137
164
|
const { cohortId } = req.params;
|
|
@@ -163,7 +190,7 @@ export async function listCohortsByClient( req, res ) {
|
|
|
163
190
|
logger.info( { message: req.query, function: 'listCohortsByClient' } );
|
|
164
191
|
const query = {
|
|
165
192
|
query: {
|
|
166
|
-
match: { clientId },
|
|
193
|
+
match: { clientId, isDeleted: false },
|
|
167
194
|
},
|
|
168
195
|
size: Number( limit ),
|
|
169
196
|
from: Number( offset ),
|
|
@@ -652,6 +652,14 @@ export const listCohortsByClientValid = {
|
|
|
652
652
|
query: listCohortsByClientSchema,
|
|
653
653
|
};
|
|
654
654
|
|
|
655
|
+
const deleteCohortSchema = joi.object( {
|
|
656
|
+
cohortId: joi.string().required(),
|
|
657
|
+
} );
|
|
658
|
+
|
|
659
|
+
export const deleteCohortValid = {
|
|
660
|
+
body: deleteCohortSchema,
|
|
661
|
+
};
|
|
662
|
+
|
|
655
663
|
// ======================= CHAT STREAM API SCHEMA =======================
|
|
656
664
|
|
|
657
665
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { createCohortValid, createBulkCohortValid, updateCohortValid, getCohortValid, listCohortsByClientValid } from '../dtos/audioAnalytics.dtos.js';
|
|
4
|
+
import { createCohortValid, createBulkCohortValid, updateCohortValid, getCohortValid, listCohortsByClientValid, deleteCohortValid } from '../dtos/audioAnalytics.dtos.js';
|
|
5
5
|
import { cohortAnalysisCardValid, conversationsListValid, conversationDetailsValid, chatStreamValid } from '../dtos/audioAnalytics.dtos.js';
|
|
6
|
-
import { createCohort, createBulkCohort, updateCohort, getCohort, listCohortsByClient, chatStream } from '../controllers/audioAnalytics.controller.js';
|
|
6
|
+
import { createCohort, createBulkCohort, updateCohort, deleteCohort, getCohort, listCohortsByClient, chatStream } from '../controllers/audioAnalytics.controller.js';
|
|
7
7
|
import { getCohortAnalysisCard } from '../controllers/cohortAnalytics.controller.js';
|
|
8
8
|
import { getConversationsList, getConversationDetails } from '../controllers/conversationAnalytics.controller.js';
|
|
9
9
|
|
|
@@ -17,6 +17,7 @@ audioAnalyticsrouter.get( '/test', ( req, res ) => {
|
|
|
17
17
|
|
|
18
18
|
// Cohort Management Routes
|
|
19
19
|
audioAnalyticsrouter.post( '/create-cohort', validate( createCohortValid ), createCohort );
|
|
20
|
+
audioAnalyticsrouter.post( '/delete-cohort', validate( deleteCohortValid ), deleteCohort );
|
|
20
21
|
audioAnalyticsrouter.post( '/create-bulk-cohort', validate( createBulkCohortValid ), createBulkCohort );
|
|
21
22
|
audioAnalyticsrouter.post( '/update-cohort', validate( updateCohortValid ), updateCohort );
|
|
22
23
|
audioAnalyticsrouter.get( '/get-cohort/:cohortId', validate( getCohortValid ), getCohort );
|
|
@@ -66,23 +66,23 @@ export async function getConversationsListFromLambda( params ) {
|
|
|
66
66
|
try {
|
|
67
67
|
const LAMBDA_ENDPOINT = JSON.parse( process.env.URL ) || 'http://lambda-api:8000';
|
|
68
68
|
logger.info( { message: 'Calling Lambda for conversations list', params } );
|
|
69
|
-
|
|
70
|
-
const response = await axios.post( `${LAMBDA_ENDPOINT.cohortConversationList}/conversations/list`, {
|
|
69
|
+
const payload = {
|
|
71
70
|
startDate: params.startDate,
|
|
72
71
|
endDate: params.endDate,
|
|
73
72
|
storeId: params.storeId,
|
|
74
73
|
clientId: params.clientId,
|
|
75
|
-
cohort_id: params
|
|
74
|
+
cohort_id: params?.cohortType?.[0],
|
|
76
75
|
isAI: params.isAI,
|
|
77
76
|
analyticsType: params.analyticsType,
|
|
78
77
|
searchValue: params.searchValue,
|
|
79
78
|
limit: params.limit,
|
|
80
79
|
offset: params.offset,
|
|
81
|
-
}
|
|
80
|
+
};
|
|
81
|
+
const response = await axios.post( `${LAMBDA_ENDPOINT.cohortConversationList}/conversations/list`, payload, {
|
|
82
82
|
timeout: 30000,
|
|
83
83
|
} );
|
|
84
84
|
|
|
85
|
-
logger.info( { message: 'Lambda response received for conversations list', totalCount: response
|
|
85
|
+
logger.info( { message: 'Lambda response received for conversations list', payload, totalCount: response } );
|
|
86
86
|
return response.data;
|
|
87
87
|
} catch ( error ) {
|
|
88
88
|
logger.error( { error, message: 'Error calling Lambda for conversations list', params } );
|