Skip to content

Commit

Permalink
update component handling
Browse files Browse the repository at this point in the history
  • Loading branch information
matsonj committed Mar 26, 2024
1 parent 8541e5f commit cde3211
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 72 deletions.
2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

90 changes: 45 additions & 45 deletions evidence/pages/nba/historical_matchups.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!

<Dropdown
data={seasons}
name=team1_season
name=team1_season_dd
value=season
title="Team 1 Year"
>
Expand All @@ -48,7 +48,7 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
<Dropdown
data={team1}
name=team1
name=team1_dd
value=team
title="Team 1"
>
Expand All @@ -57,7 +57,7 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
<Dropdown
data={seasons}
name=team2_season
name=team2_season_dd
value=season
title="Team 2 Year"
>
Expand All @@ -66,7 +66,7 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
<Dropdown
data={team2}
name=team2
name=team2_dd
value=team
title="Team 2"
>
Expand All @@ -75,15 +75,15 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
```sql team1_history
select * from nba_elo_history.nba_elo
where season = '${inputs.team1_season}'
and ( team1 = '${inputs.team1}' OR team2 = '${inputs.team1}')
where season = '${inputs.team1_season_dd.value}'
and ( team1 = '${inputs.team1_dd.value}' OR team2 = '${inputs.team1_dd.value}')
order by date
```

```sql team2_history
select * from nba_elo_history.nba_elo
where season = '${inputs.team2_season}'
and ( team1 = '${inputs.team2}' OR team2 = '${inputs.team2}')
where season = '${inputs.team2_season_dd.value}'
and ( team1 = '${inputs.team2_dd.value}' OR team2 = '${inputs.team2_dd.value}')
order by date
```

Expand All @@ -97,31 +97,31 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
playoff,
case when score1 > score2 then team1 else team2 end as winner,
case when score1 < score2 then team1 else team2 end as loser,
case when team1 = '${inputs.team1}' then elo1_pre else elo2_pre end as elo,
case when team1 = '${inputs.team1}' then score1 else score2 end as pf,
case when team1 = '${inputs.team1}' then score2 else score1 end as pa,
'${inputs.team1}' || ':' || '${inputs.team1_season}' as key,
from ${elo_history } where (team1 = '${inputs.team1}' OR team2 = '${inputs.team1}') AND season = '${inputs.team1_season}'
case when team1 = '${inputs.team1_dd.value}' then elo1_pre else elo2_pre end as elo,
case when team1 = '${inputs.team1_dd.value}' then score1 else score2 end as pf,
case when team1 = '${inputs.team1_dd.value}' then score2 else score1 end as pa,
'${inputs.team1_dd.value}' || ':' || '${inputs.team1_season_dd.value}' as key,
from ${elo_history } where (team1 = '${inputs.team1_dd.value}' OR team2 = '${inputs.team1_dd.value}') AND season = '${inputs.team1_season_dd.value}'
)
select
key,
count(*) as ct,
count(*) filter (where winner = '${inputs.team1}' and playoff = 'r') as wins,
-count(*) filter (where loser = '${inputs.team1}' and playoff = 'r') as losses,
count(*) filter (where winner = '${inputs.team1}' and team1 = '${inputs.team1}' and playoff = 'r') as home_wins,
-count(*) filter (where loser = '${inputs.team1}' and team1 = '${inputs.team1}' and playoff = 'r') as home_losses,
count(*) filter (where winner = '${inputs.team1}' and team2 = '${inputs.team1}' and playoff = 'r') as away_wins,
-count(*) filter (where loser = '${inputs.team1}' and team2 = '${inputs.team1}' and playoff = 'r') as away_losses,
count(*) filter (where winner = '${inputs.team1}' and playoff <> 'r') as playoff_wins,
-count(*) filter (where loser = '${inputs.team1}' and playoff <> 'r') as playoff_losses,
count(*) filter (where winner = '${inputs.team1_dd.value}' and playoff = 'r') as wins,
-count(*) filter (where loser = '${inputs.team1_dd.value}' and playoff = 'r') as losses,
count(*) filter (where winner = '${inputs.team1_dd.value}' and team1 = '${inputs.team1_dd.value}' and playoff = 'r') as home_wins,
-count(*) filter (where loser = '${inputs.team1_dd.value}' and team1 = '${inputs.team1_dd.value}' and playoff = 'r') as home_losses,
count(*) filter (where winner = '${inputs.team1_dd.value}' and team2 = '${inputs.team1_dd.value}' and playoff = 'r') as away_wins,
-count(*) filter (where loser = '${inputs.team1_dd.value}' and team2 = '${inputs.team1_dd.value}' and playoff = 'r') as away_losses,
count(*) filter (where winner = '${inputs.team1_dd.value}' and playoff <> 'r') as playoff_wins,
-count(*) filter (where loser = '${inputs.team1_dd.value}' and playoff <> 'r') as playoff_losses,
avg(pf) as pf,
avg(-pa) as pa,
avg(pf) - avg(pa) as margin,
min(elo) as min_elo,
avg(elo) as avg_elo,
max(elo) as max_elo,
'${inputs.team1}' as team,
'${inputs.team1_season}' as season
'${inputs.team1_dd.value}' as team,
'${inputs.team1_season_dd.value}' as season
from cte_games
GROUP BY ALL
```
Expand All @@ -136,31 +136,31 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
playoff,
case when score1 > score2 then team1 else team2 end as winner,
case when score1 < score2 then team1 else team2 end as loser,
case when team1 = '${inputs.team2}' then elo1_pre else elo2_pre end as elo,
case when team1 = '${inputs.team2}' then score1 else score2 end as pf,
case when team1 = '${inputs.team2}' then score2 else score1 end as pa,
'${inputs.team2}' || ':' || '${inputs.team2_season}' as key,
from ${elo_history } where (team1 = '${inputs.team2}' OR team2 = '${inputs.team2}') AND season = '${inputs.team2_season}'
case when team1 = '${inputs.team2_dd.value}' then elo1_pre else elo2_pre end as elo,
case when team1 = '${inputs.team2_dd.value}' then score1 else score2 end as pf,
case when team1 = '${inputs.team2_dd.value}' then score2 else score1 end as pa,
'${inputs.team2_dd.value}' || ':' || '${inputs.team2_season_dd.value}' as key,
from ${elo_history } where (team1 = '${inputs.team2_dd.value}' OR team2 = '${inputs.team2_dd.value}') AND season = '${inputs.team2_season_dd.value}'
)
select
key,
count(*) as ct,
count(*) filter (where winner = '${inputs.team2}' and playoff = 'r') as wins,
-count(*) filter (where loser = '${inputs.team2}' and playoff = 'r') as losses,
count(*) filter (where winner = '${inputs.team2}' and team1 = '${inputs.team2}' and playoff = 'r') as home_wins,
-count(*) filter (where loser = '${inputs.team2}' and team1 = '${inputs.team2}' and playoff = 'r') as home_losses,
count(*) filter (where winner = '${inputs.team2}' and team2 = '${inputs.team2}' and playoff = 'r') as away_wins,
-count(*) filter (where loser = '${inputs.team2}' and team2 = '${inputs.team2}' and playoff = 'r') as away_losses,
count(*) filter (where winner = '${inputs.team2}' and playoff <> 'r') as playoff_wins,
-count(*) filter (where loser = '${inputs.team2}' and playoff <> 'r') as playoff_losses,
count(*) filter (where winner = '${inputs.team2_dd.value}' and playoff = 'r') as wins,
-count(*) filter (where loser = '${inputs.team2_dd.value}' and playoff = 'r') as losses,
count(*) filter (where winner = '${inputs.team2_dd.value}' and team1 = '${inputs.team2_dd.value}' and playoff = 'r') as home_wins,
-count(*) filter (where loser = '${inputs.team2_dd.value}' and team1 = '${inputs.team2_dd.value}' and playoff = 'r') as home_losses,
count(*) filter (where winner = '${inputs.team2_dd.value}' and team2 = '${inputs.team2_dd.value}' and playoff = 'r') as away_wins,
-count(*) filter (where loser = '${inputs.team2_dd.value}' and team2 = '${inputs.team2_dd.value}' and playoff = 'r') as away_losses,
count(*) filter (where winner = '${inputs.team2_dd.value}' and playoff <> 'r') as playoff_wins,
-count(*) filter (where loser = '${inputs.team2_dd.value}' and playoff <> 'r') as playoff_losses,
avg(pf) as pf,
avg(-pa) as pa,
avg(pf) - avg(pa) as margin,
min(elo) as min_elo,
avg(elo) as avg_elo,
max(elo) as max_elo,
'${inputs.team2}' as team,
'${inputs.team2_season}' as season
'${inputs.team2_dd.value}' as team,
'${inputs.team2_season_dd.value}' as season
from cte_games
GROUP BY ALL
```
Expand Down Expand Up @@ -189,8 +189,8 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
abs(u2.value::int) as "team2",
CASE WHEN u2.value > u1.value THEN '' ELSE '' END AS "t2"
from cte_stats s
left join cte_unpivot u1 on u1.stat = s.stat and u1.key = '${inputs.team1}' || ':' || '${inputs.team1_season}'
left join cte_unpivot u2 on u2.stat = s.stat and u2.key = '${inputs.team2}' || ':' || '${inputs.team2_season}'
left join cte_unpivot u1 on u1.stat = s.stat and u1.key = '${inputs.team1_dd.value}' || ':' || '${inputs.team1_season_dd.value}'
left join cte_unpivot u2 on u2.stat = s.stat and u2.key = '${inputs.team2_dd.value}' || ':' || '${inputs.team2_season_dd.value}'
```

## Head to Head Stats
Expand All @@ -209,15 +209,15 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
with cte_games AS (
select
date,
case when team1 = '${inputs.team1}' then elo1_post else elo2_post end as elo,
'${inputs.team1}' || ':' || '${inputs.team1_season}' as key,
from ${elo_history } where (team1 = '${inputs.team1}' OR team2 = '${inputs.team1}') AND season = '${inputs.team1_season}'
case when team1 = '${inputs.team1_dd.value}' then elo1_post else elo2_post end as elo,
'${inputs.team1_dd.value}' || ':' || '${inputs.team1_season_dd.value}' as key,
from ${elo_history } where (team1 = '${inputs.team1_dd.value}' OR team2 = '${inputs.team1_dd.value}') AND season = '${inputs.team1_season_dd.value}'
)
select
key,
date,
elo,
'${inputs.team1_season}' || ' ' || '${inputs.team1}' as team,
'${inputs.team1_season_dd.value}' || ' ' || '${inputs.team1_dd.value}' as team,
ROW_NUMBER() OVER (ORDER BY date) as game_id
from cte_games
```
Expand All @@ -234,7 +234,7 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
key,
date,
elo,
'${inputs.team2_season}' || ' ' || '${inputs.team2}' as team,
'${inputs.team2_season_dd.value}' || ' ' || '${inputs.team2_dd.value}' as team,
ROW_NUMBER() OVER (ORDER BY date) as game_id
from cte_games
```
Expand Down
4 changes: 2 additions & 2 deletions evidence/pages/nba/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ order by team
```sql filtered_future_games
select *
from ${future_games}
where home like '${inputs.team}' OR visitor like '${inputs.team}'
where home like '${inputs.team_dd.value}' OR visitor like '${inputs.team_dd.value}'
```

# NBA Monte Carlo Simulator
Expand All @@ -31,7 +31,7 @@ This data was last updated as of <Value data={thru_date} column=end_date/>.

<Dropdown
data={teams}
name=team
name=team_dd
value=team
title="Select a Team"
>
Expand Down
44 changes: 22 additions & 22 deletions evidence/pages/nba/matchup_calc.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ queries:
```sql filtered_future_games
select *
from ${future_games}
where home = '${inputs.home_team}'
AND visitor = '${inputs.away_team}'
where home = '${inputs.home_team_dd.value}'
AND visitor = '${inputs.away_team_dd.value}'
```

# Experimental: Matchup Calculator
Expand All @@ -119,7 +119,7 @@ It is experimental and can both break in unexpected ways and return incorrect in

<Dropdown
data={teams_alpha_sort}
name=home_team
name=home_team_dd
value=team
title="Select Home Team"
>
Expand All @@ -128,14 +128,14 @@ It is experimental and can both break in unexpected ways and return incorrect in
<Dropdown
data={teams_alpha_sort}
name=away_team
name=away_team_dd
value=team
title="Select Away Team"
>
<DropdownOption valueLabel="None" value=" " />
</Dropdown>
{#if inputs.away_team != " " && inputs.home_team != " "}
{#if inputs.away_team_dd.value != " " && inputs.home_team_dd.value != " "}


# <Value data={filtered_future_games} column=visitor/> @ <Value data={filtered_future_games} column=home/>
Expand All @@ -144,19 +144,19 @@ It is experimental and can both break in unexpected ways and return incorrect in

### Team Matchup

_<Value data={summary_by_team.filter(st => st.team === inputs.away_team)} column=team/> (<Value data={summary_by_team.filter(st =>
st.team === inputs.away_team)} column=record/>) | elo <Value data={summary_by_team.filter(st => st.team === inputs.away_team)}
_<Value data={summary_by_team.filter(st => st.team === inputs.away_team_dd.value)} column=team/> (<Value data={summary_by_team.filter(st =>
st.team === inputs.away_team_dd.value)} column=record/>) | elo <Value data={summary_by_team.filter(st => st.team === inputs.away_team_dd.value)}
column=elo_rating/> | Rk: <Value data={summary_by_team.filter(st =>
st.team === inputs.away_team)} column=elo_rank/>_ <br> _<Value data={season_stats.filter(st =>
st.team === inputs.away_team)} column=points_for_num1/> ppg | <Value data={season_stats.filter(st =>
st.team === inputs.away_team)} column=avg_margin_num1/> avg. margin_<br>
st.team === inputs.away_team_dd.value)} column=elo_rank/>_ <br> _<Value data={season_stats.filter(st =>
st.team === inputs.away_team_dd.value)} column=points_for_num1/> ppg | <Value data={season_stats.filter(st =>
st.team === inputs.away_team_dd.value)} column=avg_margin_num1/> avg. margin_<br>
_<Value data={summary_by_team.filter(st =>
st.team === inputs.home_team)} column=team/> (<Value data={summary_by_team.filter(st =>
st.team === inputs.home_team)} column=record/>) | elo <Value data={summary_by_team.filter(st =>
st.team === inputs.home_team)} column=elo_rating/> | Rk: <Value data={summary_by_team.filter(st =>
st.team === inputs.home_team)} column=elo_rank/>_ <br> _<Value data={season_stats.filter(st =>
st.team === inputs.home_team)} column=points_for_num1/> ppg | <Value data={season_stats.filter(st =>
st.team === inputs.home_team)} column=avg_margin_num1/> avg. margin_
st.team === inputs.home_team_dd.value)} column=team/> (<Value data={summary_by_team.filter(st =>
st.team === inputs.home_team_dd.value)} column=record/>) | elo <Value data={summary_by_team.filter(st =>
st.team === inputs.home_team_dd.value)} column=elo_rating/> | Rk: <Value data={summary_by_team.filter(st =>
st.team === inputs.home_team_dd.value)} column=elo_rank/>_ <br> _<Value data={season_stats.filter(st =>
st.team === inputs.home_team_dd.value)} column=points_for_num1/> ppg | <Value data={season_stats.filter(st =>
st.team === inputs.home_team_dd.value)} column=avg_margin_num1/> avg. margin_

</center>

Expand All @@ -172,14 +172,14 @@ Diff. of <Value data={filtered_future_games} column=elo_diff_hfa/> **->** <Value
<script>

$: test_val = Math.min(
...game_trend.filter(gt => (inputs.home_team == gt.team || inputs.away_team == gt.team)
...game_trend.filter(gt => (inputs.home_team_dd.value == gt.team || inputs.away_team_dd.value == gt.team)
).map(item => item.elo_rating)
)

</script>

<LineChart
data={game_trend.filter(gt => (inputs.home_team == gt.team || inputs.away_team == gt.team))}
data={game_trend.filter(gt => (inputs.home_team_dd.value == gt.team || inputs.away_team_dd.value == gt.team))}
x=date
y=elo_post
title='elo change over time'
Expand All @@ -194,10 +194,10 @@ Diff. of <Value data={filtered_future_games} column=elo_diff_hfa/> **->** <Value
}
/>

## Last 5 Games - <Value data={summary_by_team.filter(st => st.team == inputs.away_team)} column=team/>
## Last 5 Games - <Value data={summary_by_team.filter(st => st.team == inputs.away_team_dd.value)} column=team/>

<DataTable
data={most_recent_games.filter(rg => (inputs.away_team == rg.visiting_team || inputs.away_team == rg.home_team ))}
data={most_recent_games.filter(rg => (inputs.away_team_dd.value == rg.visiting_team || inputs.away_team_dd.value == rg.home_team ))}
rows=5>
<Column id=matchup/>
<Column id=T title=" "/>
Expand All @@ -206,10 +206,10 @@ Diff. of <Value data={filtered_future_games} column=elo_diff_hfa/> **->** <Value
<Column id=elo_change_num1/>
</DataTable>

## Last 5 Games - <Value data={summary_by_team.filter(st => st.team ==inputs.home_team)} column=team/>
## Last 5 Games - <Value data={summary_by_team.filter(st => st.team ==inputs.home_team_dd.value)} column=team/>

<DataTable
data={most_recent_games.filter(rg => (inputs.home_team == rg.visiting_team || inputs.home_team == rg.home_team ))}
data={most_recent_games.filter(rg => (inputs.home_team_dd.value == rg.visiting_team || inputs.home_team_dd.value == rg.home_team ))}
rows=5>
<Column id=matchup/>
<Column id=T title=" "/>
Expand Down
4 changes: 2 additions & 2 deletions evidence/pages/nba/predictions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ order by team
```sql filtered_future_games
select * EXCLUDE (game_id), game_id::int as game_id
from ${future_games}
where home like '${inputs.team}' OR visitor like '${inputs.team}'
where home like '${inputs.team_dropdown.value}' OR visitor like '${inputs.team_dropdown.value}'
```

# Predictions
Expand Down Expand Up @@ -54,7 +54,7 @@ _Historically, NBA teams win 62% of their games at home, which explains why team

<Dropdown
data={teams}
name=team
name=team_dropdown
value=team
title="Select a Team"
>
Expand Down

0 comments on commit cde3211

Please sign in to comment.