Skip to content

Commit

Permalink
Merge pull request #145 from moonstream-to/api-updates-tuning-deployment
Browse files Browse the repository at this point in the history
Changes to api queries for tuning deployment.
  • Loading branch information
kellan-simiotics authored Feb 22, 2024
2 parents 3907a99 + e6ac9d5 commit f81bfdd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
22 changes: 11 additions & 11 deletions api/queries/home_run_leaderboard.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)
Expand Down
4 changes: 3 additions & 1 deletion api/queries/pitch_distribution.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/queries/player_stats_atbat.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions api/queries/strikeout_leaderboard.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)
Expand Down
4 changes: 3 additions & 1 deletion api/queries/swing_distribution.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f81bfdd

Please sign in to comment.