tango-app-api-audit 3.5.47 → 3.5.49
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 );
|
|
@@ -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',
|
|
@@ -1788,8 +1787,8 @@ export async function summaryList( req, res ) {
|
|
|
1788
1787
|
} else {
|
|
1789
1788
|
exportData.push( {
|
|
1790
1789
|
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
1791
|
-
...( req?.user?.
|
|
1792
|
-
...( req?.user?.
|
|
1790
|
+
...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
|
|
1791
|
+
...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
|
|
1793
1792
|
'Store Name': element?._source?.storeName,
|
|
1794
1793
|
'Store Name': element?._source?.storeName,
|
|
1795
1794
|
'Store ID': element?._source?.storeId || 'Un Assigned',
|
|
@@ -1823,14 +1822,113 @@ export async function summaryList( req, res ) {
|
|
|
1823
1822
|
let RMEmail = '';
|
|
1824
1823
|
let clusterName='';
|
|
1825
1824
|
if ( item?._source?.storeId&&item?._source?.storeId!='' ) {
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1825
|
+
const rmListQuery =[
|
|
1826
|
+
{
|
|
1827
|
+
$match: {
|
|
1828
|
+
$and: [
|
|
1829
|
+
{
|
|
1830
|
+
clientId: { $eq: inputData?.clientId },
|
|
1831
|
+
},
|
|
1832
|
+
{
|
|
1833
|
+
configureType: { $eq: 'user' },
|
|
1834
|
+
},
|
|
1835
|
+
],
|
|
1836
|
+
},
|
|
1837
|
+
},
|
|
1838
|
+
{
|
|
1839
|
+
$unwind: {
|
|
1840
|
+
path: '$userList', preserveNullAndEmptyArrays: true,
|
|
1841
|
+
},
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
$group: {
|
|
1845
|
+
_id: null,
|
|
1846
|
+
list: { $addToSet: '$userList.email' },
|
|
1847
|
+
},
|
|
1848
|
+
},
|
|
1849
|
+
{
|
|
1850
|
+
$project: {
|
|
1851
|
+
_id: 0,
|
|
1852
|
+
list: 1,
|
|
1853
|
+
},
|
|
1854
|
+
},
|
|
1855
|
+
];
|
|
1856
|
+
const getRMList = await aggregateEyeTestConfig( rmListQuery );
|
|
1857
|
+
let getCluster = [];
|
|
1858
|
+
if ( getRMList && getRMList?.length > 0 ) {
|
|
1859
|
+
const getRMQuery = [
|
|
1860
|
+
{
|
|
1861
|
+
$unwind: {
|
|
1862
|
+
path: '$Teamlead', preserveNullAndEmptyArrays: true,
|
|
1863
|
+
},
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
$match: {
|
|
1867
|
+
$and: [
|
|
1868
|
+
{ 'stores.storeId': { $eq: item?._source?.storeId } },
|
|
1869
|
+
{
|
|
1870
|
+
'Teamlead.email': { $in: getRMList[0].list },
|
|
1871
|
+
},
|
|
1872
|
+
],
|
|
1873
|
+
},
|
|
1874
|
+
},
|
|
1875
|
+
{
|
|
1876
|
+
$group: {
|
|
1877
|
+
_id: null,
|
|
1878
|
+
clusterName: { $addToSet: '$clusterName' },
|
|
1879
|
+
rmList: { $addToSet: '$Teamlead.email' },
|
|
1880
|
+
},
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
$project: {
|
|
1884
|
+
_id: 0,
|
|
1885
|
+
clusterName: 1,
|
|
1886
|
+
rmList: 1,
|
|
1887
|
+
},
|
|
1888
|
+
},
|
|
1889
|
+
];
|
|
1890
|
+
getCluster = await aggregateClusters( getRMQuery );
|
|
1891
|
+
}
|
|
1892
|
+
// const getCluster = await findOneClusters( { 'stores.storeId': element?._source?.storeId }, { Teamlead: 1, clusterName: 1 } );
|
|
1893
|
+
RMEmail =( getCluster && getCluster?.[0]?.rmList?.length > 0 )? getCluster?.[0]?.rmList?.toString() : '';
|
|
1894
|
+
clusterName = ( getCluster && getCluster?.[0]?.clusterName?.length > 0 )? getCluster?.[0]?.clusterName?.toString() : '';
|
|
1895
|
+
|
|
1896
|
+
if ( RMEmail && RMEmail !== '' ) {
|
|
1897
|
+
const temp = await aggregateUser( [
|
|
1898
|
+
{
|
|
1899
|
+
$match: {
|
|
1900
|
+
$and: [
|
|
1901
|
+
{
|
|
1902
|
+
email: { $in: getCluster[0]?.rmList },
|
|
1903
|
+
},
|
|
1904
|
+
{
|
|
1905
|
+
isActive: true,
|
|
1906
|
+
},
|
|
1907
|
+
{
|
|
1908
|
+
role: { $eq: 'admin' },
|
|
1909
|
+
},
|
|
1910
|
+
],
|
|
1911
|
+
},
|
|
1912
|
+
},
|
|
1913
|
+
{
|
|
1914
|
+
$group: {
|
|
1915
|
+
_id: null,
|
|
1916
|
+
user: { $addToSet: '$userName' },
|
|
1917
|
+
},
|
|
1918
|
+
},
|
|
1919
|
+
{
|
|
1920
|
+
$project: {
|
|
1921
|
+
_id: 0,
|
|
1922
|
+
user: 1,
|
|
1923
|
+
},
|
|
1924
|
+
},
|
|
1925
|
+
] );
|
|
1926
|
+
if ( temp && temp?.[0]?.user?.length >0 ) {
|
|
1927
|
+
RMName = temp?.[0]?.user?.toString( '' );
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1833
1930
|
}
|
|
1931
|
+
|
|
1834
1932
|
const testDuration = item?._source?.testDuration;
|
|
1835
1933
|
const minutes = Math.floor( testDuration / 60 );
|
|
1836
1934
|
const seconds = testDuration % 60;
|
|
@@ -2078,7 +2176,7 @@ export async function summaryCard( req, res ) {
|
|
|
2078
2176
|
initialValue.totalFiles =temp?.totalFiles?.value;
|
|
2079
2177
|
initialValue.completedFiles =temp?.completedFiles?.doc_count;
|
|
2080
2178
|
initialValue.completedRatio =Math.round( temp?.completedRatio?.value || 0 );
|
|
2081
|
-
initialValue.tangoScore =Math.round( temp?.tangoScore?.value || 0 );
|
|
2179
|
+
initialValue.tangoScore =Math.round( temp?.tangoScore?.value || 0 )+ ' %';
|
|
2082
2180
|
initialValue.tangoScoreTrend =temp?.tangoScoreTrend?.value || 0;
|
|
2083
2181
|
initialValue.trustScore =temp?.trustScore?.avg_val?.value == null || temp?.trustScore?.avg_val?.value === undefined ? 'NA':Math.round( temp?.trustScore?.avg_val?.value );
|
|
2084
2182
|
initialValue.trend = initialValue.tangoScoreTrend < 0? false : true;
|