@@ -149,7 +149,7 @@ export async function insertMatch(
149149 const match = transformMatch ( origMatch ) ;
150150 // Use the passed pgroup if gcdata or parsed, otherwise build it
151151 // Do this after removing anonymous account IDs
152- const pgroup = options . pgroup ?? getPGroup ( match as ApiMatch ) ;
152+ const pgroup = options . pgroup ?? getPGroup ( match as ApiData ) ;
153153
154154 let isProTier = false ;
155155 if ( 'leagueid' in match && match . leagueid ) {
@@ -209,7 +209,7 @@ export async function insertMatch(
209209 // Only if API or parse data
210210 return ;
211211 }
212- if ( options . type === 'api' && ! isProMatch ( match as ApiMatch ) ) {
212+ if ( options . type === 'api' && ! isProMatch ( match as ApiData ) ) {
213213 // Check whether we care about this match for pro purposes
214214 // We need the basic match data to run the check, so only do it if type is api
215215 // console.log('[UPSERTMATCHPOSTGRES]: skipping due to check');
@@ -505,14 +505,14 @@ export async function insertMatch(
505505 // Update temporary match counts/hero rankings
506506 if ( options . origin === 'scanner' && options . type === 'api' ) {
507507 await Promise . all ( [
508- updateHeroRankings ( match as ApiMatch ) ,
509- upsertMatchSample ( match as ApiMatch ) ,
510- updateRecords ( match as ApiMatch ) ,
511- updateLastPlayed ( match as ApiMatch ) ,
512- updateHeroSearch ( match as ApiMatch ) ,
513- updateHeroCounts ( match as ApiMatch , isProTier ) ,
514- updateMatchCounts ( match as ApiMatch ) ,
515- updateBenchmarks ( match as ApiMatch ) ,
508+ updateHeroRankings ( match as ApiData ) ,
509+ upsertMatchSample ( match as ApiData ) ,
510+ updateRecords ( match as ApiData ) ,
511+ updateLastPlayed ( match as ApiData ) ,
512+ updateHeroSearch ( match as ApiData ) ,
513+ updateHeroCounts ( match as ApiData , isProTier ) ,
514+ updateMatchCounts ( match as ApiData ) ,
515+ updateBenchmarks ( match as ApiData ) ,
516516 ] ) ;
517517 }
518518 }
@@ -537,7 +537,7 @@ export async function insertMatch(
537537 }
538538 async function queueMmr ( match : InsertMatchInput ) {
539539 // Trigger an update for player rank_tier if ranked match
540- const arr = match . players . filter < ApiPlayer > ( ( p ) : p is ApiPlayer => {
540+ const arr = match . players . filter < ApiDataPlayer > ( ( p ) : p is ApiDataPlayer => {
541541 return Boolean (
542542 options . origin === 'scanner' &&
543543 options . type === 'api' &&
@@ -762,7 +762,7 @@ export async function upsertPlayerCaches(
762762 ) ;
763763}
764764
765- async function updateHeroRankings ( match : ApiMatch ) {
765+ async function updateHeroRankings ( match : ApiData ) {
766766 if ( ! isSignificant ( match ) ) {
767767 return ;
768768 }
@@ -802,7 +802,7 @@ async function updateHeroRankings(match: ApiMatch) {
802802 ) ;
803803}
804804
805- async function upsertMatchSample ( match : ApiMatch ) {
805+ async function upsertMatchSample ( match : ApiData ) {
806806 if (
807807 isSignificant ( match ) &&
808808 match . match_id % 100 < Number ( config . PUBLIC_SAMPLE_PERCENT )
@@ -829,24 +829,24 @@ async function upsertMatchSample(match: ApiMatch) {
829829 }
830830}
831831async function updateRecord (
832- field : keyof ApiMatch | keyof ApiPlayer ,
833- match : ApiMatch ,
834- player : ApiPlayer ,
832+ field : keyof ApiData | keyof ApiDataPlayer ,
833+ match : ApiData ,
834+ player : ApiDataPlayer ,
835835) {
836836 redis . zadd (
837837 `records:${ field } ` ,
838- ( match [ field as keyof ApiMatch ] ||
839- player [ field as keyof ApiPlayer ] ) as number ,
838+ ( match [ field as keyof ApiData ] ||
839+ player [ field as keyof ApiDataPlayer ] ) as number ,
840840 [ match . match_id , match . start_time , player . hero_id ] . join ( ':' ) ,
841841 ) ;
842842 // Keep only 100 top scores
843843 redis . zremrangebyrank ( `records:${ field } ` , '0' , '-101' ) ;
844844 const expire = moment . utc ( ) . add ( 1 , 'month' ) . startOf ( 'month' ) . format ( 'X' ) ;
845845 redis . expireat ( `records:${ field } ` , expire ) ;
846846}
847- async function updateRecords ( match : ApiMatch ) {
847+ async function updateRecords ( match : ApiData ) {
848848 if ( isSignificant ( match ) && match . lobby_type === 7 ) {
849- updateRecord ( 'duration' , match , { } as ApiPlayer ) ;
849+ updateRecord ( 'duration' , match , { } as ApiDataPlayer ) ;
850850 match . players . forEach ( ( player ) => {
851851 updateRecord ( 'kills' , match , player ) ;
852852 updateRecord ( 'deaths' , match , player ) ;
@@ -861,7 +861,7 @@ async function updateRecords(match: ApiMatch) {
861861 } ) ;
862862 }
863863}
864- async function updateLastPlayed ( match : ApiMatch ) {
864+ async function updateLastPlayed ( match : ApiData ) {
865865 const filteredPlayers = match . players . filter (
866866 ( player ) =>
867867 player . account_id && player . account_id !== getAnonymousAccountId ( ) ,
@@ -902,7 +902,7 @@ async function updateLastPlayed(match: ApiMatch) {
902902/**
903903 * Update table storing heroes played in a game for lookup of games by heroes played
904904 * */
905- async function updateHeroSearch ( match : ApiMatch ) {
905+ async function updateHeroSearch ( match : ApiData ) {
906906 const radiant = [ ] ;
907907 const dire = [ ] ;
908908 for ( let i = 0 ; i < match . players . length ; i += 1 ) {
@@ -934,7 +934,7 @@ async function updateHeroSearch(match: ApiMatch) {
934934 ) ;
935935}
936936
937- async function updateHeroCounts ( match : ApiMatch , isProTier : boolean ) {
937+ async function updateHeroCounts ( match : ApiData , isProTier : boolean ) {
938938 // If match has leagueid, update pro picks and wins
939939 // If turbo, update picks and wins
940940 // Otherwise, update pub picks and wins if significant
@@ -996,13 +996,13 @@ async function updateHeroCounts(match: ApiMatch, isProTier: boolean) {
996996 }
997997}
998998
999- async function updateMatchCounts ( match : ApiMatch ) {
999+ async function updateMatchCounts ( match : ApiData ) {
10001000 await redisCount ( `${ match . game_mode } _game_mode` as MetricName ) ;
10011001 await redisCount ( `${ match . lobby_type } _lobby_type` as MetricName ) ;
10021002 await redisCount ( `${ match . cluster } _cluster` as MetricName ) ;
10031003}
10041004
1005- async function updateBenchmarks ( match : ApiMatch ) {
1005+ async function updateBenchmarks ( match : ApiData ) {
10061006 if (
10071007 match . match_id % 100 < Number ( config . BENCHMARKS_SAMPLE_PERCENT ) &&
10081008 isSignificant ( match )
0 commit comments