tango-app-api-audio-analytics 1.0.5 → 1.0.6
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
|
@@ -65,7 +65,13 @@ export async function updateCohort( req, res ) {
|
|
|
65
65
|
updatedAt: new Date().toISOString(),
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
// Wrap in doc object for OpenSearch update request
|
|
69
|
+
const updatePayload = {
|
|
70
|
+
doc: updateData,
|
|
71
|
+
doc_as_upsert: true,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const result = await updateOpenSearchData( 'tango-audio-config', cohortId, updatePayload );
|
|
69
75
|
logger.info( { result } );
|
|
70
76
|
|
|
71
77
|
if ( result && result.body && result.body.result === 'updated' ) {
|
|
@@ -537,12 +537,32 @@ export const createCohortValid = {
|
|
|
537
537
|
body: createCohortSchema,
|
|
538
538
|
};
|
|
539
539
|
|
|
540
|
+
const cohortUpdateMetricSchema = joi.object( {
|
|
541
|
+
metricName: joi.string().required(),
|
|
542
|
+
metricDescription: joi.string().required(),
|
|
543
|
+
isNumeric: joi.boolean().optional().default( false ),
|
|
544
|
+
metricId: joi.string().optional(),
|
|
545
|
+
minValue: joi.when( 'isNumeric', {
|
|
546
|
+
is: true,
|
|
547
|
+
then: joi.number().optional().default( null ).allow( null ),
|
|
548
|
+
otherwise: joi.forbidden(),
|
|
549
|
+
} ),
|
|
550
|
+
|
|
551
|
+
maxValue: joi.when( 'isNumeric', {
|
|
552
|
+
is: true,
|
|
553
|
+
then: joi.number().optional().default( null ).allow( null ),
|
|
554
|
+
otherwise: joi.forbidden(),
|
|
555
|
+
} ),
|
|
556
|
+
|
|
557
|
+
contexts: joi.array().items( cohortContextNonNumericSchema ).optional(),
|
|
558
|
+
} );
|
|
559
|
+
|
|
540
560
|
const updateCohortSchema = joi.object( {
|
|
541
561
|
cohortId: joi.string().required(),
|
|
542
562
|
cohortName: joi.string().optional(),
|
|
543
563
|
cohortDescription: joi.string().optional(),
|
|
544
564
|
source: joi.array().optional(),
|
|
545
|
-
metrics: joi.array().items(
|
|
565
|
+
metrics: joi.array().items( cohortUpdateMetricSchema ).optional(),
|
|
546
566
|
} );
|
|
547
567
|
|
|
548
568
|
export const updateCohortValid = {
|
|
@@ -162,7 +162,13 @@ export const updateCohort = async ( documentId, updateData ) => {
|
|
|
162
162
|
updatedAt: new Date().toISOString(),
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
// Wrap in doc object for OpenSearch update request
|
|
166
|
+
const updatePayload = {
|
|
167
|
+
doc: updateDocument,
|
|
168
|
+
doc_as_upsert: true,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const result = await updateOpenSearchData( OPENSEARCH_INDEX, documentId, updatePayload );
|
|
166
172
|
|
|
167
173
|
logger.info( `Cohort updated successfully: ${documentId}`, result );
|
|
168
174
|
|