@@ -2,53 +2,27 @@ import type { PipelineStage } from "mongoose";
22
33const tz = "Europe/Moscow" ;
44
5- export const pAchTotalPulls = ( userId : number ) : PipelineStage [ ] => [
6- { $match : { user_id : userId } } ,
7- { $count : "count" } ,
8- ] ;
5+ export const pAchTotalPulls = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId } } , { $count : "count" } ] ;
96
10- export const pAchTotalSize = ( userId : number ) : PipelineStage [ ] => [
11- { $match : { user_id : userId } } ,
12- { $group : { _id : null , total : { $sum : "$size" } } } ,
13- ] ;
7+ export const pAchTotalSize = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId } } , { $group : { _id : null , total : { $sum : "$size" } } } ] ;
148
15- export const pAchSniper30cm = ( userId : number ) : PipelineStage [ ] => [
16- { $match : { user_id : userId , size : 30 } } ,
17- { $count : "count" } ,
18- ] ;
9+ export const pAchSniper30cm = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId , size : 30 } } , { $count : "count" } ] ;
1910
20- export const pAchHalfHundred50cm = ( userId : number ) : PipelineStage [ ] => [
21- { $match : { user_id : userId , size : 50 } } ,
22- { $count : "count" } ,
23- ] ;
11+ export const pAchHalfHundred50cm = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId , size : 50 } } , { $count : "count" } ] ;
2412
25- export const pAchMaximalist61cm = ( userId : number ) : PipelineStage [ ] => [
26- { $match : { user_id : userId , size : 61 } } ,
27- { $count : "count" } ,
28- ] ;
13+ export const pAchMaximalist61cm = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId , size : 61 } } , { $count : "count" } ] ;
2914
3015export const pAchBeautifulNumbers = ( userId : number ) : PipelineStage [ ] => [
3116 { $match : { user_id : userId , size : { $in : [ 11 , 22 , 33 , 44 , 55 ] } } } ,
3217 { $group : { _id : "$size" } } ,
3318 { $count : "count" } ,
3419] ;
3520
36- export const pAchRecent10 = ( userId : number ) : PipelineStage [ ] => [
37- { $match : { user_id : userId } } ,
38- { $sort : { requested_at : - 1 } } ,
39- { $limit : 10 } ,
40- { $sort : { requested_at : 1 } } ,
41- ] ;
21+ export const pAchRecent10 = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId } } , { $sort : { requested_at : - 1 } } , { $limit : 10 } , { $sort : { requested_at : 1 } } ] ;
4222
43- export const pAchMaxSize = ( userId : number ) : PipelineStage [ ] => [
44- { $match : { user_id : userId } } ,
45- { $group : { _id : null , max : { $max : "$size" } } } ,
46- ] ;
23+ export const pAchMaxSize = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId } } , { $group : { _id : null , max : { $max : "$size" } } } ] ;
4724
48- export const pAchMinSize = ( userId : number ) : PipelineStage [ ] => [
49- { $match : { user_id : userId } } ,
50- { $group : { _id : null , min : { $min : "$size" } } } ,
51- ] ;
25+ export const pAchMinSize = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId } } , { $group : { _id : null , min : { $min : "$size" } } } ] ;
5226
5327export const pAchEarlyBird = ( userId : number ) : PipelineStage [ ] => [
5428 { $match : { user_id : userId } } ,
@@ -155,22 +129,11 @@ export const pAchLightning = (userId: number): PipelineStage[] => [
155129 { $count : "count" } ,
156130] ;
157131
158- export const pAchLast31 = ( userId : number ) : PipelineStage [ ] => [
159- { $match : { user_id : userId } } ,
160- { $sort : { requested_at : - 1 } } ,
161- { $limit : 31 } ,
162- ] ;
132+ export const pAchLast31 = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId } } , { $sort : { requested_at : - 1 } } , { $limit : 31 } ] ;
163133
164- export const pAchRecent3 = ( userId : number ) : PipelineStage [ ] => [
165- { $match : { user_id : userId } } ,
166- { $sort : { requested_at : - 1 } } ,
167- { $limit : 3 } ,
168- { $sort : { requested_at : 1 } } ,
169- ] ;
134+ export const pAchRecent3 = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId } } , { $sort : { requested_at : - 1 } } , { $limit : 3 } , { $sort : { requested_at : 1 } } ] ;
170135
171- export const pGlobalMaxMin = ( ) : PipelineStage [ ] => [
172- { $group : { _id : null , max : { $max : "$size" } , min : { $min : "$size" } } } ,
173- ] ;
136+ export const pGlobalMaxMin = ( ) : PipelineStage [ ] => [ { $group : { _id : null , max : { $max : "$size" } , min : { $min : "$size" } } } ] ;
174137
175138export const pCountSeasons = ( userId : number ) : PipelineStage [ ] => [
176139 { $group : { _id : null , first_cock_date : { $min : "$requested_at" } } } ,
@@ -192,10 +155,7 @@ export const pCountSeasons = (userId: number): PipelineStage[] => [
192155 {
193156 $project : {
194157 months_diff : {
195- $subtract : [
196- { $add : [ { $multiply : [ "$year" , 12 ] } , "$month" ] } ,
197- { $add : [ { $multiply : [ "$first_year" , 12 ] } , "$first_month" ] } ,
198- ] ,
158+ $subtract : [ { $add : [ { $multiply : [ "$year" , 12 ] } , "$month" ] } , { $add : [ { $multiply : [ "$first_year" , 12 ] } , "$first_month" ] } ] ,
199159 } ,
200160 } ,
201161 } ,
@@ -209,11 +169,7 @@ export const pCountSeasons = (userId: number): PipelineStage[] => [
209169 { $count : "count" } ,
210170] ;
211171
212- export const pCheckTraveler = ( userId : number ) : PipelineStage [ ] => [
213- { $match : { user_id : userId } } ,
214- { $group : { _id : "$size" } } ,
215- { $count : "unique_sizes" } ,
216- ] ;
172+ export const pCheckTraveler = ( userId : number ) : PipelineStage [ ] => [ { $match : { user_id : userId } } , { $group : { _id : "$size" } } , { $count : "unique_sizes" } ] ;
217173
218174export const pCheckMuscovite = ( userId : number , startDate : Date ) : PipelineStage [ ] => [
219175 { $match : { user_id : userId , size : 50 , requested_at : { $gte : startDate } } } ,
0 commit comments