@@ -7,19 +7,18 @@ const { Sentry } = require("../sentry");
77const {
88 EXPIRE_1M ,
99 EXPIRE_24H ,
10- EXPIRE_1W ,
10+ EXPIRE_48H ,
1111 EXPIRE_7D ,
1212 EXPIRE_14D ,
13- EXPIRE_48H ,
1413 TOTAL_CONFIRMATIONS_COLLECTION ,
1514 TOTAL_CONFIRMATIONS_24H ,
16- TOTAL_CONFIRMATIONS_7D ,
1715 TOTAL_CONFIRMATIONS_48H ,
16+ TOTAL_CONFIRMATIONS_7D ,
1817 TOTAL_CONFIRMATIONS_14D ,
1918 TOTAL_VOLUME_COLLECTION ,
2019 TOTAL_VOLUME_24H ,
21- TOTAL_VOLUME_7D ,
2220 TOTAL_VOLUME_48H ,
21+ TOTAL_VOLUME_7D ,
2322 TOTAL_VOLUME_14D ,
2423 CONFIRMATIONS_PER_SECOND ,
2524} = require ( "../constants" ) ;
@@ -85,22 +84,22 @@ cron.schedule("*/10 * * * * *", async () => {
8584 . then ( ( [ { totalConfirmations24h = 0 } = { } ] ) => {
8685 nodeCache . set ( TOTAL_CONFIRMATIONS_24H , totalConfirmations24h ) ;
8786 } ) ;
88- // conf 7d
87+
8988 database
9089 . collection ( TOTAL_CONFIRMATIONS_COLLECTION )
9190 . aggregate ( [
9291 {
9392 $match : {
9493 createdAt : {
95- $gte : new Date ( Date . now ( ) - EXPIRE_1W * 1000 ) ,
94+ $gte : new Date ( Date . now ( ) - EXPIRE_48H * 1000 ) ,
9695 } ,
9796 } ,
9897 } ,
99- { $group : { _id : null , totalConfirmations7d : { $sum : "$value" } } } ,
98+ { $group : { _id : null , totalConfirmations48h : { $sum : "$value" } } } ,
10099 ] )
101100 . toArray ( )
102- . then ( ( [ { totalConfirmations7d = 0 } = { } ] ) => {
103- nodeCache . set ( TOTAL_CONFIRMATIONS_7D , totalConfirmations7d ) ;
101+ . then ( ( [ { totalConfirmations48h = 0 } = { } ] ) => {
102+ nodeCache . set ( TOTAL_CONFIRMATIONS_48H , totalConfirmations48h ) ;
104103 } ) ;
105104
106105 database
@@ -109,15 +108,15 @@ cron.schedule("*/10 * * * * *", async () => {
109108 {
110109 $match : {
111110 createdAt : {
112- $lt : new Date ( Date . now ( ) + EXPIRE_48H * 1000 ) ,
111+ $gte : new Date ( Date . now ( ) - EXPIRE_14D * 1000 ) ,
113112 } ,
114113 } ,
115114 } ,
116- { $group : { _id : null , totalConfirmations48h : { $sum : "$value" } } } ,
115+ { $group : { _id : null , totalConfirmations7d : { $sum : "$value" } } } ,
117116 ] )
118117 . toArray ( )
119- . then ( ( [ { totalConfirmations48h = 0 } = { } ] ) => {
120- nodeCache . set ( TOTAL_CONFIRMATIONS_48H , totalConfirmations48h ) ;
118+ . then ( ( [ { totalConfirmations7d = 0 } = { } ] ) => {
119+ nodeCache . set ( TOTAL_CONFIRMATIONS_7D , totalConfirmations7d ) ;
121120 } ) ;
122121
123122 //conf 1w
@@ -144,7 +143,7 @@ cron.schedule("*/10 * * * * *", async () => {
144143 {
145144 $match : {
146145 createdAt : {
147- $lt : new Date ( Date . now ( ) + EXPIRE_24H * 1000 ) ,
146+ $gte : new Date ( Date . now ( ) - EXPIRE_24H * 1000 ) ,
148147 } ,
149148 } ,
150149 } ,
@@ -178,7 +177,7 @@ cron.schedule("*/10 * * * * *", async () => {
178177 {
179178 $match : {
180179 createdAt : {
181- $lt : new Date ( Date . now ( ) + TOTAL_VOLUME_14D * 1000 ) ,
180+ $lt : new Date ( Date . now ( ) + TOTAL_VOLUME_14D * 1000 ) ,
182181 } ,
183182 } ,
184183 } ,
@@ -195,7 +194,7 @@ cron.schedule("*/10 * * * * *", async () => {
195194 {
196195 $match : {
197196 createdAt : {
198- $lt : new Date ( Date . now ( ) + EXPIRE_48H * 1000 ) ,
197+ $gte : new Date ( Date . now ( ) - EXPIRE_48H * 1000 ) ,
199198 } ,
200199 } ,
201200 } ,
0 commit comments