tango-app-api-audit 3.5.48 → 3.5.50
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
|
@@ -7,7 +7,7 @@ import timezone from 'dayjs/plugin/timezone.js';
|
|
|
7
7
|
import 'dayjs/locale/en.js';
|
|
8
8
|
import { aggregateEyeTestConfig, findOneEyeTestConfig, updateOneEyeTestConfig } from '../service/eyeTestConfiguration.service.js';
|
|
9
9
|
import { ObjectId } from 'mongodb';
|
|
10
|
-
import { aggregateClusters
|
|
10
|
+
import { aggregateClusters } from '../service/clusters.service.js';
|
|
11
11
|
|
|
12
12
|
dayjs.extend( utc );
|
|
13
13
|
dayjs.extend( timezone );
|
|
@@ -1466,7 +1466,7 @@ export async function summaryList( req, res ) {
|
|
|
1466
1466
|
} );
|
|
1467
1467
|
} else {
|
|
1468
1468
|
exportData.push( {
|
|
1469
|
-
'
|
|
1469
|
+
'Clusters Name': element?.clusterName,
|
|
1470
1470
|
'Stores Count': element?.storesCount,
|
|
1471
1471
|
'Total Tango AI Files': element.totalFiles,
|
|
1472
1472
|
'Trust Audit Completed': element.completedFiles,
|
|
@@ -1726,51 +1726,50 @@ export async function summaryList( req, res ) {
|
|
|
1726
1726
|
];
|
|
1727
1727
|
getCluster = await aggregateClusters( getRMQuery );
|
|
1728
1728
|
}
|
|
1729
|
-
|
|
1730
1729
|
// const getCluster = await findOneClusters( { 'stores.storeId': element?._source?.storeId }, { Teamlead: 1, clusterName: 1 } );
|
|
1731
|
-
RMEmail =( getCluster && getCluster?.rmList?.length > 0 )? getCluster?.rmList?.toString() : '';
|
|
1732
|
-
clusterName = ( getCluster && getCluster?.clusterName?.length > 0 )? getCluster?.clusterName?.toString() : '';
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1730
|
+
RMEmail =( getCluster && getCluster?.[0]?.rmList?.length > 0 )? getCluster?.[0]?.rmList?.toString() : '';
|
|
1731
|
+
clusterName = ( getCluster && getCluster?.[0]?.clusterName?.length > 0 )? getCluster?.[0]?.clusterName?.toString() : '';
|
|
1732
|
+
if ( RMEmail && RMEmail !== '' ) {
|
|
1733
|
+
const temp = await aggregateUser( [
|
|
1734
|
+
{
|
|
1735
|
+
$match: {
|
|
1736
|
+
$and: [
|
|
1737
|
+
{
|
|
1738
|
+
email: { $in: getCluster?.[0]?.rmList },
|
|
1739
|
+
},
|
|
1740
|
+
{
|
|
1741
|
+
isActive: true,
|
|
1742
|
+
},
|
|
1743
|
+
{
|
|
1744
|
+
role: { $eq: 'admin' },
|
|
1745
|
+
},
|
|
1746
|
+
],
|
|
1747
|
+
},
|
|
1749
1748
|
},
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1749
|
+
{
|
|
1750
|
+
$group: {
|
|
1751
|
+
_id: null,
|
|
1752
|
+
user: { $addToSet: '$userName' },
|
|
1753
|
+
},
|
|
1755
1754
|
},
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1755
|
+
{
|
|
1756
|
+
$project: {
|
|
1757
|
+
_id: 0,
|
|
1758
|
+
user: 1,
|
|
1759
|
+
},
|
|
1761
1760
|
},
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1761
|
+
] );
|
|
1762
|
+
if ( temp && temp?.[0]?.user?.length >0 ) {
|
|
1763
|
+
RMName = temp?.[0]?.user?.toString( '' );
|
|
1764
|
+
}
|
|
1765
|
+
logger.info( { RMEmail: RMEmail } );
|
|
1766
1766
|
}
|
|
1767
|
-
logger.info( { RMEmail: RMEmail } );
|
|
1768
1767
|
}
|
|
1769
1768
|
if ( element?._source?.type == 'physical' ) {
|
|
1770
1769
|
exportData.push( {
|
|
1771
1770
|
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
1772
|
-
...( req?.user?.
|
|
1773
|
-
...( req?.user?.
|
|
1771
|
+
...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
|
|
1772
|
+
...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
|
|
1774
1773
|
'Store Name': element?._source?.storeName,
|
|
1775
1774
|
'Store ID': element?._source?.storeId || 'Un Assigned',
|
|
1776
1775
|
'Store Name': element?._source?.storeName ||'Un Assigned',
|
|
@@ -1778,9 +1777,11 @@ export async function summaryList( req, res ) {
|
|
|
1778
1777
|
'Queue ID': element?._source?.queueId,
|
|
1779
1778
|
'Tango Score': `${element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0} %`,
|
|
1780
1779
|
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1781
|
-
'Trust Score':
|
|
1780
|
+
'Trust Score': element?._source?.trustScore == null || element?._source?.trustScore ==undefined ? 'NA' : `${element?._source?.trustScore} %`,
|
|
1782
1781
|
'Visitor Type': element?._source?.visitorsType,
|
|
1783
1782
|
'Test Duration': duration || '',
|
|
1783
|
+
'Eye Test Status': element?._source?.comment == 'Possible Fake Video' ? 'Fake':'Genuine',
|
|
1784
|
+
'Comments ': element._source?.subComment || '',
|
|
1784
1785
|
'Audit Status': element?._source?.auditStatus || '',
|
|
1785
1786
|
'Audited By': userName?.userName || '',
|
|
1786
1787
|
|
|
@@ -1788,8 +1789,8 @@ export async function summaryList( req, res ) {
|
|
|
1788
1789
|
} else {
|
|
1789
1790
|
exportData.push( {
|
|
1790
1791
|
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
1791
|
-
...( req?.user?.
|
|
1792
|
-
...( req?.user?.
|
|
1792
|
+
...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
|
|
1793
|
+
...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
|
|
1793
1794
|
'Store Name': element?._source?.storeName,
|
|
1794
1795
|
'Store Name': element?._source?.storeName,
|
|
1795
1796
|
'Store ID': element?._source?.storeId || 'Un Assigned',
|
|
@@ -1797,8 +1798,10 @@ export async function summaryList( req, res ) {
|
|
|
1797
1798
|
'Engagement ID': element?._source?.engagementId,
|
|
1798
1799
|
'Tango Score': `${element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0} %`,
|
|
1799
1800
|
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1800
|
-
'Trust Score': `${element?._source?.trustScore
|
|
1801
|
+
'Trust Score': element?._source?.trustScore == null || element?._source?.trustScore ==undefined ? 'NA' : `${element?._source?.trustScore} %`,
|
|
1801
1802
|
'Test Duration': duration || '',
|
|
1803
|
+
'Eye Test Status': element._source?.comment,
|
|
1804
|
+
'Comments ': element._source?.subComment || '',
|
|
1802
1805
|
'Audit Status': element?._source?.auditStatus || '',
|
|
1803
1806
|
'Audited By': userName?.userName || '',
|
|
1804
1807
|
|
|
@@ -1823,14 +1826,113 @@ export async function summaryList( req, res ) {
|
|
|
1823
1826
|
let RMEmail = '';
|
|
1824
1827
|
let clusterName='';
|
|
1825
1828
|
if ( item?._source?.storeId&&item?._source?.storeId!='' ) {
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1829
|
+
const rmListQuery =[
|
|
1830
|
+
{
|
|
1831
|
+
$match: {
|
|
1832
|
+
$and: [
|
|
1833
|
+
{
|
|
1834
|
+
clientId: { $eq: inputData?.clientId },
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
configureType: { $eq: 'user' },
|
|
1838
|
+
},
|
|
1839
|
+
],
|
|
1840
|
+
},
|
|
1841
|
+
},
|
|
1842
|
+
{
|
|
1843
|
+
$unwind: {
|
|
1844
|
+
path: '$userList', preserveNullAndEmptyArrays: true,
|
|
1845
|
+
},
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
$group: {
|
|
1849
|
+
_id: null,
|
|
1850
|
+
list: { $addToSet: '$userList.email' },
|
|
1851
|
+
},
|
|
1852
|
+
},
|
|
1853
|
+
{
|
|
1854
|
+
$project: {
|
|
1855
|
+
_id: 0,
|
|
1856
|
+
list: 1,
|
|
1857
|
+
},
|
|
1858
|
+
},
|
|
1859
|
+
];
|
|
1860
|
+
const getRMList = await aggregateEyeTestConfig( rmListQuery );
|
|
1861
|
+
let getCluster = [];
|
|
1862
|
+
if ( getRMList && getRMList?.length > 0 ) {
|
|
1863
|
+
const getRMQuery = [
|
|
1864
|
+
{
|
|
1865
|
+
$unwind: {
|
|
1866
|
+
path: '$Teamlead', preserveNullAndEmptyArrays: true,
|
|
1867
|
+
},
|
|
1868
|
+
},
|
|
1869
|
+
{
|
|
1870
|
+
$match: {
|
|
1871
|
+
$and: [
|
|
1872
|
+
{ 'stores.storeId': { $eq: item?._source?.storeId } },
|
|
1873
|
+
{
|
|
1874
|
+
'Teamlead.email': { $in: getRMList[0].list },
|
|
1875
|
+
},
|
|
1876
|
+
],
|
|
1877
|
+
},
|
|
1878
|
+
},
|
|
1879
|
+
{
|
|
1880
|
+
$group: {
|
|
1881
|
+
_id: null,
|
|
1882
|
+
clusterName: { $addToSet: '$clusterName' },
|
|
1883
|
+
rmList: { $addToSet: '$Teamlead.email' },
|
|
1884
|
+
},
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
$project: {
|
|
1888
|
+
_id: 0,
|
|
1889
|
+
clusterName: 1,
|
|
1890
|
+
rmList: 1,
|
|
1891
|
+
},
|
|
1892
|
+
},
|
|
1893
|
+
];
|
|
1894
|
+
getCluster = await aggregateClusters( getRMQuery );
|
|
1895
|
+
}
|
|
1896
|
+
// const getCluster = await findOneClusters( { 'stores.storeId': element?._source?.storeId }, { Teamlead: 1, clusterName: 1 } );
|
|
1897
|
+
RMEmail =( getCluster && getCluster?.[0]?.rmList?.length > 0 )? getCluster?.[0]?.rmList?.toString() : '';
|
|
1898
|
+
clusterName = ( getCluster && getCluster?.[0]?.clusterName?.length > 0 )? getCluster?.[0]?.clusterName?.toString() : '';
|
|
1899
|
+
|
|
1900
|
+
if ( RMEmail && RMEmail !== '' ) {
|
|
1901
|
+
const temp = await aggregateUser( [
|
|
1902
|
+
{
|
|
1903
|
+
$match: {
|
|
1904
|
+
$and: [
|
|
1905
|
+
{
|
|
1906
|
+
email: { $in: getCluster[0]?.rmList },
|
|
1907
|
+
},
|
|
1908
|
+
{
|
|
1909
|
+
isActive: true,
|
|
1910
|
+
},
|
|
1911
|
+
{
|
|
1912
|
+
role: { $eq: 'admin' },
|
|
1913
|
+
},
|
|
1914
|
+
],
|
|
1915
|
+
},
|
|
1916
|
+
},
|
|
1917
|
+
{
|
|
1918
|
+
$group: {
|
|
1919
|
+
_id: null,
|
|
1920
|
+
user: { $addToSet: '$userName' },
|
|
1921
|
+
},
|
|
1922
|
+
},
|
|
1923
|
+
{
|
|
1924
|
+
$project: {
|
|
1925
|
+
_id: 0,
|
|
1926
|
+
user: 1,
|
|
1927
|
+
},
|
|
1928
|
+
},
|
|
1929
|
+
] );
|
|
1930
|
+
if ( temp && temp?.[0]?.user?.length >0 ) {
|
|
1931
|
+
RMName = temp?.[0]?.user?.toString( '' );
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1833
1934
|
}
|
|
1935
|
+
|
|
1834
1936
|
const testDuration = item?._source?.testDuration;
|
|
1835
1937
|
const minutes = Math.floor( testDuration / 60 );
|
|
1836
1938
|
const seconds = testDuration % 60;
|
|
@@ -2246,7 +2348,7 @@ export async function addUserConfig( req, res, next ) {
|
|
|
2246
2348
|
const updatedOne = await updateOneEyeTestConfig( query, record, { upsert: true } );
|
|
2247
2349
|
logger.info( { updatedOne: updatedOne } );
|
|
2248
2350
|
if ( updatedOne ) {
|
|
2249
|
-
return res.sendSuccess( '
|
|
2351
|
+
return res.sendSuccess( 'Audit users added successfully' );
|
|
2250
2352
|
} else {
|
|
2251
2353
|
return res.sendError( 'Added Failed' );
|
|
2252
2354
|
}
|
|
@@ -2273,7 +2375,7 @@ export async function updateUserConfig( req, res ) {
|
|
|
2273
2375
|
const updatedOne = await updateOneEyeTestConfig( query, record, { upsert: true } );
|
|
2274
2376
|
logger.info( { updatedOne: updatedOne } );
|
|
2275
2377
|
if ( updatedOne ) {
|
|
2276
|
-
return res.sendSuccess( '
|
|
2378
|
+
return res.sendSuccess( 'Audit users updated successfully' );
|
|
2277
2379
|
} else {
|
|
2278
2380
|
return res.sendError( 'updated Failed' );
|
|
2279
2381
|
}
|