@@ -8,7 +8,17 @@ import search from '../store/search.mts';
8
8
import searchES from '../store/searchES.mts' ;
9
9
import buildMatch from '../store/buildMatch.mts' ;
10
10
import { buildStatus } from '../store/buildStatus.mts' ;
11
- import { checkIfInExperiment , countPeers , generateJob , getData , isContributor , isRadiant , matchupToString , mergeObjects , redisCount } from '../util/utility.mts' ;
11
+ import {
12
+ checkIfInExperiment ,
13
+ countPeers ,
14
+ generateJob ,
15
+ getData ,
16
+ isContributor ,
17
+ isRadiant ,
18
+ matchupToString ,
19
+ mergeObjects ,
20
+ redisCount ,
21
+ } from '../util/utility.mts' ;
12
22
import playerFields from './playerFields.mts' ;
13
23
import db from '../store/db.mts' ;
14
24
import redis from '../store/redis.mts' ;
@@ -205,7 +215,9 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
205
215
profile ( cb ) {
206
216
getPlayer ( db , accountId , ( err , playerData ) => {
207
217
if ( playerData !== null && playerData !== undefined ) {
208
- playerData . is_contributor = isContributor ( accountId . toString ( ) ) ;
218
+ playerData . is_contributor = isContributor (
219
+ accountId . toString ( )
220
+ ) ;
209
221
playerData . is_subscriber = Boolean ( playerData ?. status ) ;
210
222
}
211
223
cb ( err as any , playerData ) ;
@@ -699,9 +711,14 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
699
711
}
700
712
cache . forEach ( ( m ) => {
701
713
Object . keys ( subkeys ) . forEach ( ( key ) => {
702
- if ( m [ key as keyof ParsedPlayerMatch ] !== null && m [ key as keyof ParsedPlayerMatch ] !== undefined ) {
714
+ if (
715
+ m [ key as keyof ParsedPlayerMatch ] !== null &&
716
+ m [ key as keyof ParsedPlayerMatch ] !== undefined
717
+ ) {
703
718
result [ key ] . n += 1 ;
704
- result [ key ] . sum += Number ( m [ key as keyof ParsedPlayerMatch ] ) ;
719
+ result [ key ] . sum += Number (
720
+ m [ key as keyof ParsedPlayerMatch ]
721
+ ) ;
705
722
}
706
723
} ) ;
707
724
} ) ;
@@ -749,15 +766,22 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
749
766
cache . forEach ( ( m ) => {
750
767
m . is_radiant = isRadiant ( m ) ;
751
768
Object . keys ( countCats ) . forEach ( ( key ) => {
752
- if ( ! result [ key ] [ Math . floor ( m [ key as keyof ParsedPlayerMatch ] ) ] ) {
753
- result [ key ] [ Math . floor ( m [ key as keyof ParsedPlayerMatch ] ) ] = {
754
- games : 0 ,
755
- win : 0 ,
756
- } ;
769
+ if (
770
+ ! result [ key ] [ Math . floor ( m [ key as keyof ParsedPlayerMatch ] ) ]
771
+ ) {
772
+ result [ key ] [ Math . floor ( m [ key as keyof ParsedPlayerMatch ] ) ] =
773
+ {
774
+ games : 0 ,
775
+ win : 0 ,
776
+ } ;
757
777
}
758
- result [ key ] [ Math . floor ( m [ key as keyof ParsedPlayerMatch ] ) ] . games += 1 ;
778
+ result [ key ] [
779
+ Math . floor ( m [ key as keyof ParsedPlayerMatch ] )
780
+ ] . games += 1 ;
759
781
const won = Number ( m . radiant_win === isRadiant ( m ) ) ;
760
- result [ key ] [ Math . floor ( m [ key as keyof ParsedPlayerMatch ] ) ] . win += won ;
782
+ result [ key ] [
783
+ Math . floor ( m [ key as keyof ParsedPlayerMatch ] )
784
+ ] . win += won ;
761
785
} ) ;
762
786
} ) ;
763
787
return res . json ( result ) ;
@@ -881,7 +905,10 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
881
905
}
882
906
cache . forEach ( ( m ) => {
883
907
Object . keys ( result ) . forEach ( ( key ) => {
884
- mergeObjects ( result [ key as keyof typeof result ] , m [ key as keyof ParsedPlayerMatch ] ) ;
908
+ mergeObjects (
909
+ result [ key as keyof typeof result ] ,
910
+ m [ key as keyof ParsedPlayerMatch ]
911
+ ) ;
885
912
} ) ;
886
913
} ) ;
887
914
return res . json ( result ) ;
@@ -930,7 +957,10 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
930
957
}
931
958
cache . forEach ( ( m ) => {
932
959
Object . keys ( result ) . forEach ( ( key ) => {
933
- mergeObjects ( result [ key as keyof typeof result ] , m [ key as keyof ParsedPlayerMatch ] ) ;
960
+ mergeObjects (
961
+ result [ key as keyof typeof result ] ,
962
+ m [ key as keyof ParsedPlayerMatch ]
963
+ ) ;
934
964
} ) ;
935
965
} ) ;
936
966
return res . json ( result ) ;
@@ -1002,15 +1032,12 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
1002
1032
} ,
1003
1033
route : ( ) => '/players/:account_id/rankings' ,
1004
1034
func : ( req , res , cb ) => {
1005
- getPlayerHeroRankings (
1006
- req . params . account_id ,
1007
- ( err , result ) => {
1008
- if ( err ) {
1009
- return cb ( err ) ;
1010
- }
1011
- return res . json ( result ) ;
1035
+ getPlayerHeroRankings ( req . params . account_id , ( err , result ) => {
1036
+ if ( err ) {
1037
+ return cb ( err ) ;
1012
1038
}
1013
- ) ;
1039
+ return res . json ( result ) ;
1040
+ } ) ;
1014
1041
} ,
1015
1042
} ,
1016
1043
} ,
@@ -1465,18 +1492,12 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
1465
1492
} ,
1466
1493
route : ( ) => '/rankings' ,
1467
1494
func : ( req , res , cb ) => {
1468
- getHeroRankings (
1469
- db ,
1470
- redis ,
1471
- req . query . hero_id ,
1472
- { } ,
1473
- ( err , result ) => {
1474
- if ( err ) {
1475
- return cb ( err ) ;
1476
- }
1477
- return res . json ( result ) ;
1495
+ getHeroRankings ( db , redis , req . query . hero_id , { } , ( err , result ) => {
1496
+ if ( err ) {
1497
+ return cb ( err ) ;
1478
1498
}
1479
- ) ;
1499
+ return res . json ( result ) ;
1500
+ } ) ;
1480
1501
} ,
1481
1502
} ,
1482
1503
} ,
@@ -1551,7 +1572,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
1551
1572
try {
1552
1573
const status = await buildStatus ( ) ;
1553
1574
return res . json ( status ) ;
1554
- } catch ( e ) {
1575
+ } catch ( e ) {
1555
1576
return cb ( e ) ;
1556
1577
}
1557
1578
} ,
@@ -2108,18 +2129,12 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
2108
2129
route : ( ) => '/heroes/:hero_id/itemPopularity' ,
2109
2130
func : ( req , res , cb ) => {
2110
2131
const heroId = req . params . hero_id ;
2111
- getHeroItemPopularity (
2112
- db ,
2113
- redis ,
2114
- heroId ,
2115
- { } ,
2116
- ( err , result ) => {
2117
- if ( err ) {
2118
- return cb ( err ) ;
2119
- }
2120
- return res . json ( result ) ;
2132
+ getHeroItemPopularity ( db , redis , heroId , { } , ( err , result ) => {
2133
+ if ( err ) {
2134
+ return cb ( err ) ;
2121
2135
}
2122
- ) ;
2136
+ return res . json ( result ) ;
2137
+ } ) ;
2123
2138
} ,
2124
2139
} ,
2125
2140
} ,
0 commit comments