From e6ac9d55cdf4a471fac0f3f9866a5c1f328f10e5 Mon Sep 17 00:00:00 2001 From: Kellan Wampler Date: Wed, 7 Feb 2024 14:34:27 -0500 Subject: [PATCH] Changes to api queries for tuning deployment. --- api/queries/home_run_leaderboard.sql | 22 +++++++++++----------- api/queries/pitch_distribution.sql | 4 +++- api/queries/player_stats_atbat.sql | 2 +- api/queries/strikeout_leaderboard.sql | 22 +++++++++++----------- api/queries/swing_distribution.sql | 4 +++- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/api/queries/home_run_leaderboard.sql b/api/queries/home_run_leaderboard.sql index 203e05e7..7618de4f 100644 --- a/api/queries/home_run_leaderboard.sql +++ b/api/queries/home_run_leaderboard.sql @@ -3,9 +3,9 @@ with dedup_events as ( DISTINCT ON(transaction_hash, log_index) * FROM wyrm_labels WHERE label='moonworm-alpha' - AND address='0xde191e8c352BA59F95cf19f0931cCbBcc7B60934' + AND address='0xC90F37D09f2f8fB2e9D1Aa9a9d5142f5aE100d84' AND log_index IS NOT NULL -), SessionResolved as ( +), AtBats as ( SELECT label_data->'args'->>'sessionID' as session_id, label_data->'args'->>'outcome' as outcome, @@ -15,34 +15,34 @@ with dedup_events as ( label_data->'args'->>'pitcherTokenID' as pitcher_token_id, log_index FROM dedup_events - WHERE label_data->>'name'='SessionResolved' + WHERE label_data->>'name'='AtBatProgress' AND label_data->'args'->>'outcome'!='0' ), batter_stats as ( SELECT SUM(CASE - WHEN outcome = '0' THEN 1 ELSE 0 + WHEN outcome = '1' THEN 1 ELSE 0 END) as strikeouts, SUM(CASE - WHEN outcome = '1' THEN 1 ELSE 0 + WHEN outcome = '2' THEN 1 ELSE 0 END) as walks, SUM(CASE - WHEN outcome = '2' THEN 1 ELSE 0 + WHEN outcome = '3' THEN 1 ELSE 0 END) as singles, SUM(CASE - WHEN outcome = '3' THEN 1 ELSE 0 + WHEN outcome = '4' THEN 1 ELSE 0 END) as doubles, SUM(CASE - WHEN outcome = '4' THEN 1 ELSE 0 + WHEN outcome = '5' THEN 1 ELSE 0 END) as triples, SUM(CASE - WHEN outcome = '5' THEN 1 ELSE 0 + WHEN outcome = '6' THEN 1 ELSE 0 END) as home_runs, SUM(CASE - WHEN outcome = '6' THEN 1 ELSE 0 + WHEN outcome = '7' THEN 1 ELSE 0 END) as in_play_outs, count(*) as total_batter_events, batter_address as batter_address, batter_token_id as batter_token_id - FROM SessionResolved + FROM AtBats GROUP BY batter_address, batter_token_id ORDER BY home_runs DESC ) diff --git a/api/queries/pitch_distribution.sql b/api/queries/pitch_distribution.sql index d7fa1eb6..bbfa97ae 100644 --- a/api/queries/pitch_distribution.sql +++ b/api/queries/pitch_distribution.sql @@ -3,7 +3,9 @@ with dedup_events as ( DISTINCT ON(transaction_hash, log_index) * FROM wyrm_labels WHERE label='moonworm-alpha' - AND (address='0xde191e8c352BA59F95cf19f0931cCbBcc7B60934' OR address='0x9270df8d907A99E5024dc3532657a5cF9C7A4889') + AND (address='0xde191e8c352BA59F95cf19f0931cCbBcc7B60934' + OR address='0x9270df8d907A99E5024dc3532657a5cF9C7A4889' + OR address='0xC90F37D09f2f8fB2e9D1Aa9a9d5142f5aE100d84') AND log_index IS NOT NULL ), SessionResolved as ( SELECT diff --git a/api/queries/player_stats_atbat.sql b/api/queries/player_stats_atbat.sql index d38cd7ef..57efd652 100644 --- a/api/queries/player_stats_atbat.sql +++ b/api/queries/player_stats_atbat.sql @@ -3,7 +3,7 @@ with dedup_events as ( DISTINCT ON(transaction_hash, log_index) * FROM wyrm_labels WHERE label='moonworm-alpha' - AND address='0x9270df8d907A99E5024dc3532657a5cF9C7A4889' + AND address='0xC90F37D09f2f8fB2e9D1Aa9a9d5142f5aE100d84' AND log_index IS NOT NULL ), AtBats as ( SELECT diff --git a/api/queries/strikeout_leaderboard.sql b/api/queries/strikeout_leaderboard.sql index ad4addf5..33aef4c1 100644 --- a/api/queries/strikeout_leaderboard.sql +++ b/api/queries/strikeout_leaderboard.sql @@ -3,9 +3,9 @@ with dedup_events as ( DISTINCT ON(transaction_hash, log_index) * FROM wyrm_labels WHERE label='moonworm-alpha' - AND address='0xde191e8c352BA59F95cf19f0931cCbBcc7B60934' + AND address='0xC90F37D09f2f8fB2e9D1Aa9a9d5142f5aE100d84' AND log_index IS NOT NULL -), SessionResolved as ( +), AtBats as ( SELECT label_data->'args'->>'sessionID' as session_id, label_data->'args'->>'outcome' as outcome, @@ -15,34 +15,34 @@ with dedup_events as ( label_data->'args'->>'pitcherTokenID' as pitcher_token_id, log_index FROM dedup_events - WHERE label_data->>'name'='SessionResolved' + WHERE label_data->>'name'='AtBatProgress' AND label_data->'args'->>'outcome'!='0' ), pitcher_stats as ( SELECT SUM(CASE - WHEN outcome = '0' THEN 1 ELSE 0 + WHEN outcome = '1' THEN 1 ELSE 0 END) as strikeouts, SUM(CASE - WHEN outcome = '1' THEN 1 ELSE 0 + WHEN outcome = '2' THEN 1 ELSE 0 END) as walks, SUM(CASE - WHEN outcome = '2' THEN 1 ELSE 0 + WHEN outcome = '3' THEN 1 ELSE 0 END) as singles, SUM(CASE - WHEN outcome = '3' THEN 1 ELSE 0 + WHEN outcome = '4' THEN 1 ELSE 0 END) as doubles, SUM(CASE - WHEN outcome = '4' THEN 1 ELSE 0 + WHEN outcome = '5' THEN 1 ELSE 0 END) as triples, SUM(CASE - WHEN outcome = '5' THEN 1 ELSE 0 + WHEN outcome = '6' THEN 1 ELSE 0 END) as home_runs, SUM(CASE - WHEN outcome = '6' THEN 1 ELSE 0 + WHEN outcome = '7' THEN 1 ELSE 0 END) as in_play_outs, count(*) as total_pitcher_events, pitcher_address, pitcher_token_id - FROM SessionResolved + FROM AtBats GROUP BY pitcher_address, pitcher_token_id ORDER BY strikeouts DESC ) diff --git a/api/queries/swing_distribution.sql b/api/queries/swing_distribution.sql index 5d2ea2a5..0c7932d2 100644 --- a/api/queries/swing_distribution.sql +++ b/api/queries/swing_distribution.sql @@ -3,7 +3,9 @@ with dedup_events as ( DISTINCT ON(transaction_hash, log_index) * FROM wyrm_labels WHERE label='moonworm-alpha' - AND (address='0xde191e8c352BA59F95cf19f0931cCbBcc7B60934' OR address='0x9270df8d907A99E5024dc3532657a5cF9C7A4889') + AND (address='0xde191e8c352BA59F95cf19f0931cCbBcc7B60934' + OR address='0x9270df8d907A99E5024dc3532657a5cF9C7A4889' + OR address='0xC90F37D09f2f8fB2e9D1Aa9a9d5142f5aE100d84') AND log_index IS NOT NULL ), SessionResolved as ( SELECT