Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
2.17.0 - [CLOSE: #182, CLOSE: #183]
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalghost-dev committed Mar 18, 2024
1 parent a479ac1 commit f097df0
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 6 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

# Update History

## 2.16.1 | 2024-03-01
## 2.17.0 | 2024-03-17

### Added
* [#183](https://github.com/digitalghost-dev/premier-league/issues/183) - Added a new *Recent Injuries* section under *Players & Injuries* tab.

### Changed
* [#182](https://github.com/digitalghost-dev/premier-league/issues/182) - Changed the tab name for *Players Statistics* to *Players & Injuries*.

---

## [2.16.1] | 2024-03-01

### Changed
* [#181](https://github.com/digitalghost-dev/premier-league/issues/181) - Changed `components/connections.py` to use new dataset in BigQuery for team squads.
Expand Down Expand Up @@ -452,7 +462,9 @@ Top Teams Tab
Top Players Tab
* Shows the `portrait`, `goals`, `team`, and `nationality` of the current top five goal scorers in the league.

[2.16.0]: https://github.com/digitalghost-dev/premier-league/commit/aae9d9c814eafc905104a765c475b5763d0881f8#diff-4dc66906e3c3b7f7a82967d85af564f2d5a6e0bee5829aa5eda607dd9756c87d
[2.16.1]: https://github.com/digitalghost-dev/premier-league/commit/950590251f6559beb2376acf491a3cf1edec8a8e

[2.16.0]: https://github.com/digitalghost-dev/premier-league/commit/aae9d9c814eafc905104a765c475b5763d0881f8

[2.15.0]: https://github.com/digitalghost-dev/premier-league/commit/95aac28fbf4ab29f7965e8bc326f631198cf7272

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<p align="center">
<img src="https://img.shields.io/github/actions/workflow/status/digitalghost-dev/premier-league/ci_streamlit.yaml?style=flat-square&logo=github&label=CI%2FCD"/>
<a href="https://github.com/digitalghost-dev/premier-league/blob/main/CHANGELOG.md">
<img src="https://img.shields.io/badge/Dashboard_Version-2.16.1-FF4B4B?style=flat-square&logo=streamlit"/>
<img src="https://img.shields.io/badge/Dashboard_Version-2.17.0-FF4B4B?style=flat-square&logo=streamlit"/>
</a>
<a href="https://hub.docker.com/repository/docker/digitalghostdev/premier-league/general">
<img src="https://img.shields.io/docker/image-size/digitalghostdev/premier-league/2.16.1?style=flat-square&logo=docker&label=Image%20Size&color=0DB7ED"/>
<img src="https://img.shields.io/docker/image-size/digitalghostdev/premier-league/2.17.0?style=flat-square&logo=docker&label=Image%20Size&color=0DB7ED"/>
</a>
<img src="https://img.shields.io/github/repo-size/digitalghost-dev/premier-league?style=flat-square&label=Repo%20Size&color=DEA584">
</p>
Expand Down
11 changes: 11 additions & 0 deletions components/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ def get_squads() -> pd.DataFrame:
return pd.DataFrame(data=squads_data)


@st.cache_resource
def get_injuries() -> pd.DataFrame:
injuries_data = run_query(
"""
SELECT *
FROM `premier_league_injuries.all_teams_injuries_view`
"""
)
return pd.DataFrame(data=injuries_data)


@st.cache_resource
def get_stocks() -> pd.DataFrame:
stock_data = run_query(
Expand Down
60 changes: 60 additions & 0 deletions components/injuries_section.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import streamlit as st


class InjuriesSection:
def __init__(self, injuries_df):
self.injuries_df = injuries_df
self.teams = (
"Arsenal",
"Aston Villa",
"Bournemouth",
"Brentford",
"Brighton",
"Burnley",
"Chelsea",
"Crystal Palace",
"Everton",
"Fulham",
"Liverpool",
"Luton",
"Manchester City",
"Manchester United",
"Newcastle",
"Nottingham Forest",
"Sheffield Utd",
"Tottenham",
"West Ham",
"Wolves",
)

def display(self):
st.divider()
st.subheader("Recent Injuries")
st.write("Select the teams you want to see recent injuries for.")
popover = st.popover("Filter Teams")
filtered_df = self.injuries_df.drop(columns=["team_id", "player_id"])
team_checkboxes = {}

for team in self.teams:
team_checkboxes[team] = popover.checkbox(f"{team}", value=False)

for team, is_checked in team_checkboxes.items():
if is_checked:
team_df = filtered_df[(filtered_df["team_name"] == team)]
team_df = team_df.drop(columns=["team_name"])
st.write(f"**{team}**")
if team_df.empty:
st.write("No recent injuries reported.")
st.empty()
else:
st.dataframe(
team_df,
column_config={
"player_name": "Player",
"injury_type": "Injury Type",
"injury_reason": "Reason",
"injury_date": "Date",
},
hide_index=True,
use_container_width=True,
)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Streamlit
pandas==2.1.4
plotly==5.18.0
streamlit==1.30.0
streamlit==1.32.2

# Google Cloud
firebase-admin==6.3.0
Expand Down
9 changes: 8 additions & 1 deletion streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from components.about_section import AboutSection
from components.fixtures_section import FixturesSection
from components.highlights_section import HighlightsSection
from components.injuries_section import InjuriesSection
from components.league_form_section import LeagueFormsSection
from components.point_progression_section import PointProgressionSection
from components.point_slider_section import PointSliderSection
Expand All @@ -21,6 +22,7 @@
from components.connections import (
firestore_connection,
get_highlights,
get_injuries,
get_league_statistics,
get_max_round,
get_min_round,
Expand All @@ -46,6 +48,7 @@ def streamlit_app():
# Get the dataframes.
firestore_database = firestore_connection()
highlights_df = get_highlights()
injuries_df = get_injuries()
league_statistics_df = get_league_statistics()
max_round = get_max_round()
min_round = get_min_round()
Expand Down Expand Up @@ -89,7 +92,7 @@ def get_suffix(day):
[
"Standings & Overview",
"Teams Statistics",
"Players Statistics",
"Players & Injuries",
"Fixtures",
"Squads",
"News & Hightlights",
Expand Down Expand Up @@ -305,6 +308,10 @@ def standings_table() -> DeltaGenerator:
with st.container():
top_scorers_section.display()

injuries_section = InjuriesSection(injuries_df)
with st.container():
injuries_section.display()

# --------- Fixtures Tab ---------
# Tab 4 holds the following sections: [Fixtures].
with tab4:
Expand Down

0 comments on commit f097df0

Please sign in to comment.