tango-app-api-trax 1.0.0-alpha.13 → 1.0.0-alpha.15

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.
@@ -15,7 +15,7 @@ export const welcome = async ( req, res ) => {
15
15
  }
16
16
  };
17
17
 
18
- export const overallCards = async ( req, res ) => {
18
+ export const overallCardsOld = async ( req, res ) => {
19
19
  try {
20
20
  let requestData = req.body;
21
21
  let fromDate = new Date( requestData.fromDate );
@@ -984,7 +984,7 @@ export const checklistInfo = async ( req, res ) => {
984
984
  }
985
985
  };
986
986
 
987
- export const infoCards = async ( req, res ) => {
987
+ export const infoCardsOld = async ( req, res ) => {
988
988
  try {
989
989
  let requestData = req.body;
990
990
  let fromDate = new Date( requestData.fromDate );
@@ -1540,3 +1540,660 @@ export const flagDetectionTables = async ( req, res ) => {
1540
1540
  return res.sendError( { error: error }, 500 );
1541
1541
  }
1542
1542
  };
1543
+
1544
+ export const overallCards = async ( req, res ) => {
1545
+ try {
1546
+ let requestData = req.body;
1547
+ let resultData = await overallCardsData( requestData.checklistType );
1548
+ return res.sendSuccess( resultData );
1549
+ } catch ( error ) {
1550
+ console.log( 'error =>', error );
1551
+ logger.error( { error: error, function: 'overallCards' } );
1552
+ return res.sendError( error, 500 );
1553
+ }
1554
+ };
1555
+
1556
+ export const overallComparisonCards = async ( req, res ) => {
1557
+ try {
1558
+ let requestData = req.body;
1559
+ let resultData = await checklistComparisonData( requestData.checklistType );
1560
+ return res.sendSuccess( resultData );
1561
+ } catch ( error ) {
1562
+ console.log( 'error =>', error );
1563
+ logger.error( { error: error, function: 'overallComparisonCards' } );
1564
+ return res.sendError( error, 500 );
1565
+ }
1566
+ };
1567
+
1568
+ async function overallCardsData( checklistType ) {
1569
+ try {
1570
+ let resData = {};
1571
+ let activeUnique = 50;
1572
+ let notSubmittedInstances = {
1573
+ 'count': 300,
1574
+ 'open': 100,
1575
+ 'inprogress': 200,
1576
+ };
1577
+ let totalInstances = {
1578
+ 'count': 500,
1579
+ };
1580
+ let completedInstances = {
1581
+ 'count': 200,
1582
+ };
1583
+ let flags = {
1584
+ 'count': 50,
1585
+ };
1586
+ let completionScore = {
1587
+ 'count': 49,
1588
+ };
1589
+ let complianceRate = {
1590
+ 'count': 66,
1591
+ };
1592
+
1593
+ resData.overallCards = {
1594
+ 'activeUnique': activeUnique,
1595
+ 'totalInstances': totalInstances,
1596
+ 'notSubmittedInstances': notSubmittedInstances,
1597
+ 'completedInstances': completedInstances,
1598
+ 'flags': flags,
1599
+ 'completionScore': completionScore,
1600
+ 'complianceRate': complianceRate,
1601
+ };
1602
+
1603
+ return resData;
1604
+ } catch ( error ) {
1605
+ console.log( 'error =>', error );
1606
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1607
+ }
1608
+ }
1609
+
1610
+ async function checklistComparisonData( checklistType ) {
1611
+ try {
1612
+ let resData = {};
1613
+ let flags = {
1614
+ 'comparisonData': 40,
1615
+ 'ComparisonFlag': true,
1616
+ };
1617
+ let completionScore = {
1618
+ 'comparisonData': 20,
1619
+ 'ComparisonFlag': false,
1620
+ };
1621
+ let complianceRate = {
1622
+ 'comparisonData': 60,
1623
+ 'ComparisonFlag': true,
1624
+ };
1625
+
1626
+ resData.overallComparisonCards = {
1627
+ 'flags': flags,
1628
+ 'completionScore': completionScore,
1629
+ 'complianceRate': complianceRate,
1630
+ };
1631
+
1632
+ return resData;
1633
+ } catch ( error ) {
1634
+ console.log( 'error =>', error );
1635
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1636
+ }
1637
+ }
1638
+
1639
+ export const infoCards = async ( req, res ) => {
1640
+ try {
1641
+ let requestData = req.body;
1642
+ let resultData = await infoCardsData( requestData.checklistType );
1643
+ return res.sendSuccess( resultData );
1644
+ } catch ( error ) {
1645
+ console.log( 'error =>', error );
1646
+ logger.error( { error: error, function: 'infoCards' } );
1647
+ return res.sendError( error, 500 );
1648
+ }
1649
+ };
1650
+
1651
+ export const infoComparisonCards = async ( req, res ) => {
1652
+ try {
1653
+ let requestData = req.body;
1654
+ let resultData = await infoCardsComparisonData( requestData.checklistType );
1655
+ return res.sendSuccess( resultData );
1656
+ } catch ( error ) {
1657
+ console.log( 'error =>', error );
1658
+ logger.error( { error: error, function: 'infoComparisonCards' } );
1659
+ return res.sendError( error, 500 );
1660
+ }
1661
+ };
1662
+
1663
+ async function infoCardsData( checklistType ) {
1664
+ try {
1665
+ let resData = {};
1666
+ let activeUnique = 800;
1667
+ let notSubmittedInstances = {
1668
+ 'count': 500,
1669
+ 'open': 300,
1670
+ 'inprogress': 200,
1671
+ };
1672
+ let totalInstances = {
1673
+ 'count': 300,
1674
+ };
1675
+ let completedInstances = {
1676
+ 'count': '',
1677
+ };
1678
+ let flags = {
1679
+ 'count': '',
1680
+ };
1681
+ let completionScore = {
1682
+ 'count': '',
1683
+ };
1684
+ let complianceRate = {
1685
+ 'count': '',
1686
+ };
1687
+
1688
+ resData.overallCards = {
1689
+ 'activeUnique': activeUnique,
1690
+ 'totalInstances': totalInstances,
1691
+ 'notSubmittedInstances': notSubmittedInstances,
1692
+ 'completedInstances': completedInstances,
1693
+ 'flags': flags,
1694
+ 'completionScore': completionScore,
1695
+ 'complianceRate': complianceRate,
1696
+ };
1697
+
1698
+ return resData;
1699
+ } catch ( error ) {
1700
+ console.log( 'error =>', error );
1701
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1702
+ }
1703
+ }
1704
+
1705
+ async function infoCardsComparisonData( checklistType ) {
1706
+ try {
1707
+ let resData = {};
1708
+ let totalInstances = {
1709
+ 'comparisonData': 30,
1710
+ 'ComparisonFlag': false,
1711
+ };
1712
+ let completedInstances = {
1713
+ 'comparisonData': 50,
1714
+ 'ComparisonFlag': true,
1715
+ };
1716
+ let flags = {
1717
+ 'comparisonData': 40,
1718
+ 'ComparisonFlag': true,
1719
+ };
1720
+ let completionScore = {
1721
+ 'comparisonData': 20,
1722
+ 'ComparisonFlag': false,
1723
+ };
1724
+ let complianceRate = {
1725
+ 'comparisonData': 60,
1726
+ 'ComparisonFlag': true,
1727
+ };
1728
+
1729
+ resData.overallComparisonCards = {
1730
+ 'totalInstances': totalInstances,
1731
+ 'completedInstances': completedInstances,
1732
+ 'flags': flags,
1733
+ 'completionScore': completionScore,
1734
+ 'complianceRate': complianceRate,
1735
+ };
1736
+
1737
+ return resData;
1738
+ } catch ( error ) {
1739
+ console.log( 'error =>', error );
1740
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1741
+ }
1742
+ }
1743
+
1744
+ export const overallCardsV1 = async ( req, res ) => {
1745
+ try {
1746
+ let requestData = req.body;
1747
+ let fromDate = new Date( requestData.fromDate );
1748
+ let toDate = new Date( requestData.toDate );
1749
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
1750
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
1751
+ toDate.setUTCHours( 23, 59, 59, 59 );
1752
+ let activeUnique = 0;
1753
+ let notSubmittedInstances = {
1754
+ 'count': '',
1755
+ 'open': '',
1756
+ 'inprogress': '',
1757
+ };
1758
+ let totalInstances = {
1759
+ 'count': '',
1760
+ };
1761
+ let completedInstances = {
1762
+ 'count': '',
1763
+ };
1764
+ let flags = {
1765
+ 'count': '',
1766
+ };
1767
+ let completionScore = {
1768
+ 'count': '',
1769
+ };
1770
+ let complianceRate = {
1771
+ 'count': '',
1772
+ };
1773
+ let result = {};
1774
+
1775
+ let findQuery = [];
1776
+ let findUniqueQuery = [];
1777
+ let findAndQuery = [];
1778
+ findAndQuery.push(
1779
+ { client_id: requestData.clientId },
1780
+ { store_id: { $in: requestData.storeId } },
1781
+ { date_iso: { $gte: fromDate } },
1782
+ { date_iso: { $lte: toDate } },
1783
+ );
1784
+
1785
+ findQuery.push( { $match: { $and: findAndQuery } } );
1786
+
1787
+ findQuery.push( {
1788
+ $project: {
1789
+ sourceCheckList_id: 1,
1790
+ checkListId: 1,
1791
+ checklistStatus: 1,
1792
+ timeFlag: 1,
1793
+ questionFlag: 1,
1794
+ mobileDetectionFlag: 1,
1795
+ storeOpenCloseFlag: 1,
1796
+ uniformDetectionFlag: 1,
1797
+ markasread: 1,
1798
+ checkListType: 1,
1799
+ questionCount: 1,
1800
+ },
1801
+ } );
1802
+
1803
+ findQuery.push( {
1804
+ $group: {
1805
+ _id: '',
1806
+ totalChecklist: { $sum: 1 },
1807
+ notSubmittedChecklist: {
1808
+ $sum: {
1809
+ $cond: [
1810
+ {
1811
+ $and: [
1812
+ { $ne: [ '$checklistStatus', 'submit' ] },
1813
+ ],
1814
+ }, 1, 0 ],
1815
+ },
1816
+ },
1817
+ openChecklist: {
1818
+ $sum: {
1819
+ $cond: [
1820
+ {
1821
+ $and: [
1822
+ { $eq: [ '$checklistStatus', 'open' ] },
1823
+ ],
1824
+ }, 1, 0 ],
1825
+ },
1826
+ },
1827
+ inprogressChecklist: {
1828
+ $sum: {
1829
+ $cond: [
1830
+ {
1831
+ $and: [
1832
+ { $eq: [ '$checklistStatus', 'inprogress' ] },
1833
+ ],
1834
+ }, 1, 0 ],
1835
+ },
1836
+ },
1837
+ submittedChecklist: {
1838
+ $sum: {
1839
+ $cond: [
1840
+ {
1841
+ $and: [
1842
+ { $eq: [ '$checklistStatus', 'submit' ] },
1843
+ ],
1844
+ }, 1, 0 ],
1845
+ },
1846
+ },
1847
+ flaggedChecklist: {
1848
+ $sum: {
1849
+ $cond: [ {
1850
+ $or: [
1851
+ { $gt: [ '$timeFlag', 0 ] },
1852
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
1853
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
1854
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
1855
+ ],
1856
+ }, 1, 0 ],
1857
+ },
1858
+ },
1859
+ questionFlagCount: {
1860
+ $sum: {
1861
+ $cond: [
1862
+ {
1863
+ $and: [
1864
+ { $gt: [ '$questionFlag', 0 ] },
1865
+ ],
1866
+ }, 1, 0 ],
1867
+ },
1868
+ },
1869
+ questionCount: {
1870
+ $sum: {
1871
+ $cond: [
1872
+ {
1873
+ $and: [
1874
+ { $gt: [ '$questionCount', 0 ] },
1875
+ ],
1876
+ }, 1, 0 ],
1877
+ },
1878
+ },
1879
+ },
1880
+ } );
1881
+
1882
+ findQuery.push( {
1883
+ $project: {
1884
+ totalChecklist: 1,
1885
+ notSubmittedChecklist: 1,
1886
+ openChecklist: 1,
1887
+ inprogressChecklist: 1,
1888
+ submittedChecklist: 1,
1889
+ flaggedChecklist: 1,
1890
+ completionScore: {
1891
+ $multiply: [
1892
+ { $divide: [ '$submittedChecklist', '$totalChecklist' ] },
1893
+ 100,
1894
+ ],
1895
+ },
1896
+ questionFlagCount: 1,
1897
+ questionCount: 1,
1898
+ questionCompletionScore: {
1899
+ $multiply: [
1900
+ { $divide: [
1901
+ { $subtract: [ '$questionCount', '$questionFlagCount' ] },
1902
+ '$questionCount',
1903
+ ] },
1904
+ 100,
1905
+ ],
1906
+ },
1907
+ },
1908
+ } );
1909
+ let getOverallChecklistData = await processedchecklistService.aggregate( findQuery );
1910
+
1911
+ findUniqueQuery.push( { $match: { $and: findAndQuery } } );
1912
+ findUniqueQuery.push( {
1913
+ $project: {
1914
+ sourceCheckList_id: 1,
1915
+ },
1916
+ } );
1917
+ findUniqueQuery.push( {
1918
+ $group: {
1919
+ _id: '$sourceCheckList_id',
1920
+ },
1921
+ } );
1922
+ findUniqueQuery.push( {
1923
+ $count: 'totalUniqueChecklist',
1924
+ } );
1925
+ let getUniqueChecklistData = await processedchecklistService.aggregate( findUniqueQuery );
1926
+ if ( !getUniqueChecklistData.length && !getOverallChecklistData.length ) {
1927
+ return res.sendError( { error: 'No Data Found' }, 204 );
1928
+ }
1929
+
1930
+ if ( getUniqueChecklistData.length && getUniqueChecklistData.length>0 ) {
1931
+ if ( getUniqueChecklistData[0].totalUniqueChecklist ) {
1932
+ activeUnique = getUniqueChecklistData[0]?.totalUniqueChecklist;
1933
+ }
1934
+ }
1935
+
1936
+ if ( getOverallChecklistData.length && getOverallChecklistData.length>0 ) {
1937
+ if ( getOverallChecklistData[0].totalChecklist ) {
1938
+ totalInstances.count = getOverallChecklistData[0]?.totalChecklist;
1939
+ }
1940
+ if ( getOverallChecklistData[0].notSubmittedChecklist ) {
1941
+ notSubmittedInstances.count = getOverallChecklistData[0]?.notSubmittedChecklist;
1942
+ }
1943
+ if ( getOverallChecklistData[0].openChecklist ) {
1944
+ notSubmittedInstances.open = getOverallChecklistData[0]?.openChecklist;
1945
+ }
1946
+ if ( getOverallChecklistData[0].inprogressChecklist ) {
1947
+ notSubmittedInstances.inprogress = getOverallChecklistData[0]?.inprogressChecklist;
1948
+ }
1949
+ if ( getOverallChecklistData[0].submittedChecklist ) {
1950
+ completedInstances.count = getOverallChecklistData[0]?.submittedChecklist;
1951
+ }
1952
+ if ( getOverallChecklistData[0].flaggedChecklist ) {
1953
+ flags.count = getOverallChecklistData[0]?.flaggedChecklist;
1954
+ }
1955
+ if ( getOverallChecklistData[0].completionScore ) {
1956
+ completionScore.count = getOverallChecklistData[0]?.completionScore.toFixed( 2 );
1957
+ }
1958
+ if ( getOverallChecklistData[0].questionCompletionScore ) {
1959
+ complianceRate.count = getOverallChecklistData[0]?.questionCompletionScore.toFixed( 2 );
1960
+ }
1961
+ }
1962
+ result.overallCards = {
1963
+ 'activeUnique': activeUnique,
1964
+ 'totalInstances': totalInstances,
1965
+ 'notSubmittedInstances': notSubmittedInstances,
1966
+ 'completedInstances': completedInstances,
1967
+ 'flags': flags,
1968
+ 'completionScore': completionScore,
1969
+ 'complianceRate': complianceRate,
1970
+ };
1971
+ return res.sendSuccess( result );
1972
+ } catch ( error ) {
1973
+ logger.error( { error: error, message: req.query, function: 'overallCards' } );
1974
+ return res.sendError( { error: error }, 500 );
1975
+ }
1976
+ };
1977
+
1978
+ export const overallComparisonCardsV1 = async ( req, res ) => {
1979
+ try {
1980
+ let requestData = req.body;
1981
+ let fromDate = new Date( requestData.fromDate );
1982
+ let toDate = new Date( requestData.toDate );
1983
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
1984
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
1985
+ toDate.setUTCHours( 23, 59, 59, 59 );
1986
+ let activeUnique = 0;
1987
+ let flags = {
1988
+ 'count': '',
1989
+ };
1990
+ let completionScore = {
1991
+ 'count': '',
1992
+ };
1993
+ let complianceRate = {
1994
+ 'count': '',
1995
+ };
1996
+ let result = {};
1997
+
1998
+ let findQuery = [];
1999
+ let findUniqueQuery = [];
2000
+ let findAndQuery = [];
2001
+ findAndQuery.push(
2002
+ { client_id: requestData.clientId },
2003
+ { store_id: { $in: requestData.storeId } },
2004
+ { date_iso: { $gte: fromDate } },
2005
+ { date_iso: { $lte: toDate } },
2006
+ );
2007
+
2008
+ findQuery.push( { $match: { $and: findAndQuery } } );
2009
+
2010
+ findQuery.push( {
2011
+ $project: {
2012
+ sourceCheckList_id: 1,
2013
+ checkListId: 1,
2014
+ checklistStatus: 1,
2015
+ timeFlag: 1,
2016
+ questionFlag: 1,
2017
+ mobileDetectionFlag: 1,
2018
+ storeOpenCloseFlag: 1,
2019
+ uniformDetectionFlag: 1,
2020
+ markasread: 1,
2021
+ checkListType: 1,
2022
+ questionCount: 1,
2023
+ },
2024
+ } );
2025
+
2026
+ findQuery.push( {
2027
+ $group: {
2028
+ _id: '',
2029
+ totalChecklist: { $sum: 1 },
2030
+ notSubmittedChecklist: {
2031
+ $sum: {
2032
+ $cond: [
2033
+ {
2034
+ $and: [
2035
+ { $ne: [ '$checklistStatus', 'submit' ] },
2036
+ ],
2037
+ }, 1, 0 ],
2038
+ },
2039
+ },
2040
+ openChecklist: {
2041
+ $sum: {
2042
+ $cond: [
2043
+ {
2044
+ $and: [
2045
+ { $eq: [ '$checklistStatus', 'open' ] },
2046
+ ],
2047
+ }, 1, 0 ],
2048
+ },
2049
+ },
2050
+ inprogressChecklist: {
2051
+ $sum: {
2052
+ $cond: [
2053
+ {
2054
+ $and: [
2055
+ { $eq: [ '$checklistStatus', 'inprogress' ] },
2056
+ ],
2057
+ }, 1, 0 ],
2058
+ },
2059
+ },
2060
+ submittedChecklist: {
2061
+ $sum: {
2062
+ $cond: [
2063
+ {
2064
+ $and: [
2065
+ { $eq: [ '$checklistStatus', 'submit' ] },
2066
+ ],
2067
+ }, 1, 0 ],
2068
+ },
2069
+ },
2070
+ flaggedChecklist: {
2071
+ $sum: {
2072
+ $cond: [ {
2073
+ $or: [
2074
+ { $gt: [ '$timeFlag', 0 ] },
2075
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
2076
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
2077
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
2078
+ ],
2079
+ }, 1, 0 ],
2080
+ },
2081
+ },
2082
+ questionFlagCount: {
2083
+ $sum: {
2084
+ $cond: [
2085
+ {
2086
+ $and: [
2087
+ { $gt: [ '$questionFlag', 0 ] },
2088
+ ],
2089
+ }, 1, 0 ],
2090
+ },
2091
+ },
2092
+ questionCount: {
2093
+ $sum: {
2094
+ $cond: [
2095
+ {
2096
+ $and: [
2097
+ { $gt: [ '$questionCount', 0 ] },
2098
+ ],
2099
+ }, 1, 0 ],
2100
+ },
2101
+ },
2102
+ },
2103
+ } );
2104
+
2105
+ findQuery.push( {
2106
+ $project: {
2107
+ totalChecklist: 1,
2108
+ notSubmittedChecklist: 1,
2109
+ openChecklist: 1,
2110
+ inprogressChecklist: 1,
2111
+ submittedChecklist: 1,
2112
+ flaggedChecklist: 1,
2113
+ completionScore: {
2114
+ $multiply: [
2115
+ { $divide: [ '$submittedChecklist', '$totalChecklist' ] },
2116
+ 100,
2117
+ ],
2118
+ },
2119
+ questionFlagCount: 1,
2120
+ questionCount: 1,
2121
+ questionCompletionScore: {
2122
+ $multiply: [
2123
+ { $divide: [
2124
+ { $subtract: [ '$questionCount', '$questionFlagCount' ] },
2125
+ '$questionCount',
2126
+ ] },
2127
+ 100,
2128
+ ],
2129
+ },
2130
+ },
2131
+ } );
2132
+ let getOverallChecklistData = await processedchecklistService.aggregate( findQuery );
2133
+
2134
+ findUniqueQuery.push( { $match: { $and: findAndQuery } } );
2135
+ findUniqueQuery.push( {
2136
+ $project: {
2137
+ sourceCheckList_id: 1,
2138
+ },
2139
+ } );
2140
+ findUniqueQuery.push( {
2141
+ $group: {
2142
+ _id: '$sourceCheckList_id',
2143
+ },
2144
+ } );
2145
+ findUniqueQuery.push( {
2146
+ $count: 'totalUniqueChecklist',
2147
+ } );
2148
+ let getUniqueChecklistData = await processedchecklistService.aggregate( findUniqueQuery );
2149
+ if ( !getUniqueChecklistData.length && !getOverallChecklistData.length ) {
2150
+ return res.sendError( { error: 'No Data Found' }, 204 );
2151
+ }
2152
+
2153
+ if ( getUniqueChecklistData.length && getUniqueChecklistData.length>0 ) {
2154
+ if ( getUniqueChecklistData[0].totalUniqueChecklist ) {
2155
+ activeUnique = getUniqueChecklistData[0]?.totalUniqueChecklist;
2156
+ }
2157
+ }
2158
+
2159
+ if ( getOverallChecklistData.length && getOverallChecklistData.length>0 ) {
2160
+ if ( getOverallChecklistData[0].totalChecklist ) {
2161
+ totalInstances.count = getOverallChecklistData[0]?.totalChecklist;
2162
+ }
2163
+ if ( getOverallChecklistData[0].notSubmittedChecklist ) {
2164
+ notSubmittedInstances.count = getOverallChecklistData[0]?.notSubmittedChecklist;
2165
+ }
2166
+ if ( getOverallChecklistData[0].openChecklist ) {
2167
+ notSubmittedInstances.open = getOverallChecklistData[0]?.openChecklist;
2168
+ }
2169
+ if ( getOverallChecklistData[0].inprogressChecklist ) {
2170
+ notSubmittedInstances.inprogress = getOverallChecklistData[0]?.inprogressChecklist;
2171
+ }
2172
+ if ( getOverallChecklistData[0].submittedChecklist ) {
2173
+ completedInstances.count = getOverallChecklistData[0]?.submittedChecklist;
2174
+ }
2175
+ if ( getOverallChecklistData[0].flaggedChecklist ) {
2176
+ flags.count = getOverallChecklistData[0]?.flaggedChecklist;
2177
+ }
2178
+ if ( getOverallChecklistData[0].completionScore ) {
2179
+ completionScore.count = getOverallChecklistData[0]?.completionScore.toFixed( 2 );
2180
+ }
2181
+ if ( getOverallChecklistData[0].questionCompletionScore ) {
2182
+ complianceRate.count = getOverallChecklistData[0]?.questionCompletionScore.toFixed( 2 );
2183
+ }
2184
+ }
2185
+ result.overallCards = {
2186
+ 'activeUnique': activeUnique,
2187
+ 'totalInstances': totalInstances,
2188
+ 'notSubmittedInstances': notSubmittedInstances,
2189
+ 'completedInstances': completedInstances,
2190
+ 'flags': flags,
2191
+ 'completionScore': completionScore,
2192
+ 'complianceRate': complianceRate,
2193
+ };
2194
+ return res.sendSuccess( result );
2195
+ } catch ( error ) {
2196
+ logger.error( { error: error, message: req.query, function: 'overallCards' } );
2197
+ return res.sendError( { error: error }, 500 );
2198
+ }
2199
+ };
@@ -7,6 +7,7 @@ export const traxDashboardRouter = express.Router();
7
7
  import {
8
8
  welcome,
9
9
  overallCards,
10
+ overallComparisonCards,
10
11
  checklistPerformance,
11
12
  storePerformance,
12
13
  userPerformance,
@@ -15,19 +16,26 @@ import {
15
16
  userDropdown,
16
17
  checklistInfo,
17
18
  infoCards,
19
+ infoComparisonCards,
18
20
  monthlyGraph,
19
21
  flagDetectionCards,
20
22
  flagDetectionTables,
23
+ overallCardsV1,
24
+ overallComparisonCardsV1,
21
25
  } from '../controllers/traxDashboard.controllers.js';
22
26
 
23
27
  traxDashboardRouter
24
28
  .get( '/welcome', welcome )
25
29
  .post( '/overallCards', overallCards )
30
+ .post( '/overallCardsV1', overallCardsV1 )
31
+ .post( '/overallComparisonCards', overallComparisonCards )
32
+ .post( '/overallComparisonCardsV1', overallComparisonCardsV1 )
26
33
  .post( '/checklistPerformance', checklistPerformance )
27
34
  .post( '/storePerformance', storePerformance )
28
35
  .post( '/userPerformance', userPerformance )
29
36
  .post( '/checklistInfo', checklistInfo )
30
37
  .post( '/infoCards', infoCards )
38
+ .post( '/infoComparisonCards', infoComparisonCards )
31
39
  .post( '/monthlyGraph', monthlyGraph )
32
40
  .post( '/checklistDropdown', checklistDropdown )
33
41
  .post( '/storelistDropdown', storeDropdown )