Spaces:
Sleeping
Sleeping
nataliaElv
commited on
Commit
Β·
58bba8c
1
Parent(s):
0b2c5d2
fine-tune tables
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import datetime
|
|
| 9 |
g = Github(st.secrets["ACCESS_TOKEN"])
|
| 10 |
repo = g.get_repo(st.secrets["REPO_NAME"])
|
| 11 |
|
|
|
|
| 12 |
def fetch_data():
|
| 13 |
|
| 14 |
issues_data = []
|
|
@@ -34,18 +35,22 @@ def fetch_data():
|
|
| 34 |
def save_data(df):
|
| 35 |
df.to_json("issues.json", orient="records", indent=4, index=False)
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
st.title(f"GitHub Issues Dashboard for {repo.name}")
|
| 39 |
status = st.status(label="Loading data...", state="running")
|
| 40 |
|
| 41 |
-
|
| 42 |
-
df = pd.read_json("issues.json", convert_dates=["Created at", "Closed at", "Last update"], date_unit="ms")
|
| 43 |
-
except:
|
| 44 |
-
df = fetch_data()
|
| 45 |
-
save_data(df)
|
| 46 |
|
| 47 |
today = datetime.date.today()
|
| 48 |
-
one_month_ago = today - datetime.timedelta(days=30)
|
| 49 |
|
| 50 |
# Section 1: Issue activity metrics
|
| 51 |
st.header("Issue activity metrics")
|
|
@@ -88,7 +93,7 @@ with col3:
|
|
| 88 |
st.subheader("Latest updates π")
|
| 89 |
col1, col2 = st.columns(2)
|
| 90 |
with col1:
|
| 91 |
-
last_update_date = st.date_input("Last updated after:", value=
|
| 92 |
last_update_date = datetime.datetime.combine(last_update_date, datetime.datetime.min.time()) # Convert to datetime object
|
| 93 |
with col2:
|
| 94 |
updated_issues = open_issues[open_issues["Last update"] > last_update_date]
|
|
@@ -97,18 +102,19 @@ with col2:
|
|
| 97 |
st.dataframe(
|
| 98 |
updated_issues[["Issue","Labels", "Last update","URL"]].sort_values(by="Last update", ascending=False),
|
| 99 |
hide_index=True,
|
| 100 |
-
use_container_width=True,
|
| 101 |
column_config={
|
| 102 |
-
"Issue": st.column_config.TextColumn("Issue", width=
|
| 103 |
-
"
|
| 104 |
-
"
|
|
|
|
| 105 |
}
|
| 106 |
)
|
| 107 |
|
| 108 |
st.subheader("Stale issues? πΈοΈ")
|
| 109 |
col1, col2 = st.columns(2)
|
| 110 |
with col1:
|
| 111 |
-
not_updated_since = st.date_input("Not updated since:", value=
|
| 112 |
not_updated_since = datetime.datetime.combine(not_updated_since, datetime.datetime.min.time()) # Convert to datetime object
|
| 113 |
with col2:
|
| 114 |
stale_issues = open_issues[open_issues["Last update"] < not_updated_since]
|
|
@@ -116,11 +122,12 @@ with col2:
|
|
| 116 |
st.dataframe(
|
| 117 |
stale_issues[["Issue","Labels", "Last update","URL"]].sort_values(by="Last update", ascending=True),
|
| 118 |
hide_index=True,
|
| 119 |
-
use_container_width=True,
|
| 120 |
column_config={
|
| 121 |
-
"Issue": st.column_config.TextColumn("Issue", width=
|
| 122 |
-
"
|
| 123 |
-
"
|
|
|
|
| 124 |
}
|
| 125 |
)
|
| 126 |
|
|
@@ -157,11 +164,11 @@ with col2:
|
|
| 157 |
st.subheader("Cloud of words βοΈ")
|
| 158 |
titles = " ".join(open_issues["Issue"])
|
| 159 |
titles = re.sub(r'\[.*?\]', '', titles)
|
| 160 |
-
wordcloud = WordCloud(width=800, height=400, background_color="
|
| 161 |
plt.figure(figsize=(10, 5))
|
| 162 |
plt.imshow(wordcloud, interpolation="bilinear")
|
| 163 |
plt.axis("off")
|
| 164 |
-
st.pyplot(plt)
|
| 165 |
|
| 166 |
# # Community engagement
|
| 167 |
st.header("Community engagement")
|
|
@@ -172,12 +179,12 @@ engagement_df = open_issues[["Issue","Reactions","Comments","URL"]].sort_values(
|
|
| 172 |
st.dataframe(
|
| 173 |
engagement_df,
|
| 174 |
hide_index=True,
|
| 175 |
-
use_container_width=True,
|
| 176 |
column_config={
|
| 177 |
-
"Issue": st.column_config.TextColumn("Issue", width=
|
| 178 |
-
"Reactions": st.column_config.NumberColumn("Reactions", format="%d π"),
|
| 179 |
-
"Comments": st.column_config.NumberColumn("Comments", format="%d π¬"),
|
| 180 |
-
"URL": st.column_config.LinkColumn("π", display_text="π")
|
| 181 |
}
|
| 182 |
)
|
| 183 |
|
|
|
|
| 9 |
g = Github(st.secrets["ACCESS_TOKEN"])
|
| 10 |
repo = g.get_repo(st.secrets["REPO_NAME"])
|
| 11 |
|
| 12 |
+
@st.cache_data
|
| 13 |
def fetch_data():
|
| 14 |
|
| 15 |
issues_data = []
|
|
|
|
| 35 |
def save_data(df):
|
| 36 |
df.to_json("issues.json", orient="records", indent=4, index=False)
|
| 37 |
|
| 38 |
+
@st.cache_data
|
| 39 |
+
def load_data():
|
| 40 |
+
try:
|
| 41 |
+
df = pd.read_json("issues.json", convert_dates=["Created at", "Closed at", "Last update"], date_unit="ms")
|
| 42 |
+
except:
|
| 43 |
+
df = fetch_data()
|
| 44 |
+
save_data(df)
|
| 45 |
+
return df
|
| 46 |
+
|
| 47 |
|
| 48 |
st.title(f"GitHub Issues Dashboard for {repo.name}")
|
| 49 |
status = st.status(label="Loading data...", state="running")
|
| 50 |
|
| 51 |
+
df = load_data()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
today = datetime.date.today()
|
|
|
|
| 54 |
|
| 55 |
# Section 1: Issue activity metrics
|
| 56 |
st.header("Issue activity metrics")
|
|
|
|
| 93 |
st.subheader("Latest updates π")
|
| 94 |
col1, col2 = st.columns(2)
|
| 95 |
with col1:
|
| 96 |
+
last_update_date = st.date_input("Last updated after:", value=today - datetime.timedelta(days=7), format="DD-MM-YYYY")
|
| 97 |
last_update_date = datetime.datetime.combine(last_update_date, datetime.datetime.min.time()) # Convert to datetime object
|
| 98 |
with col2:
|
| 99 |
updated_issues = open_issues[open_issues["Last update"] > last_update_date]
|
|
|
|
| 102 |
st.dataframe(
|
| 103 |
updated_issues[["Issue","Labels", "Last update","URL"]].sort_values(by="Last update", ascending=False),
|
| 104 |
hide_index=True,
|
| 105 |
+
# use_container_width=True,
|
| 106 |
column_config={
|
| 107 |
+
"Issue": st.column_config.TextColumn("Issue", width="large"),
|
| 108 |
+
"Labels": st.column_config.ListColumn("Labels", width="large"),
|
| 109 |
+
"Last update": st.column_config.DatetimeColumn("Last update", width="medium"),
|
| 110 |
+
"URL": st.column_config.LinkColumn("π", display_text="π", width="small")
|
| 111 |
}
|
| 112 |
)
|
| 113 |
|
| 114 |
st.subheader("Stale issues? πΈοΈ")
|
| 115 |
col1, col2 = st.columns(2)
|
| 116 |
with col1:
|
| 117 |
+
not_updated_since = st.date_input("Not updated since:", value=today - datetime.timedelta(days=90), format="DD-MM-YYYY")
|
| 118 |
not_updated_since = datetime.datetime.combine(not_updated_since, datetime.datetime.min.time()) # Convert to datetime object
|
| 119 |
with col2:
|
| 120 |
stale_issues = open_issues[open_issues["Last update"] < not_updated_since]
|
|
|
|
| 122 |
st.dataframe(
|
| 123 |
stale_issues[["Issue","Labels", "Last update","URL"]].sort_values(by="Last update", ascending=True),
|
| 124 |
hide_index=True,
|
| 125 |
+
# use_container_width=True,
|
| 126 |
column_config={
|
| 127 |
+
"Issue": st.column_config.TextColumn("Issue", width="large"),
|
| 128 |
+
"Labels": st.column_config.ListColumn("Labels", width="large"),
|
| 129 |
+
"Last update": st.column_config.DatetimeColumn("Last update", width="medium"),
|
| 130 |
+
"URL": st.column_config.LinkColumn("π", display_text="π", width="small")
|
| 131 |
}
|
| 132 |
)
|
| 133 |
|
|
|
|
| 164 |
st.subheader("Cloud of words βοΈ")
|
| 165 |
titles = " ".join(open_issues["Issue"])
|
| 166 |
titles = re.sub(r'\[.*?\]', '', titles)
|
| 167 |
+
wordcloud = WordCloud(width=800, height=400, background_color="black").generate(titles)
|
| 168 |
plt.figure(figsize=(10, 5))
|
| 169 |
plt.imshow(wordcloud, interpolation="bilinear")
|
| 170 |
plt.axis("off")
|
| 171 |
+
st.pyplot(plt, use_container_width=True)
|
| 172 |
|
| 173 |
# # Community engagement
|
| 174 |
st.header("Community engagement")
|
|
|
|
| 179 |
st.dataframe(
|
| 180 |
engagement_df,
|
| 181 |
hide_index=True,
|
| 182 |
+
# use_container_width=True,
|
| 183 |
column_config={
|
| 184 |
+
"Issue": st.column_config.TextColumn("Issue", width="large"),
|
| 185 |
+
"Reactions": st.column_config.NumberColumn("Reactions", format="%d π", width="small"),
|
| 186 |
+
"Comments": st.column_config.NumberColumn("Comments", format="%d π¬", width="small"),
|
| 187 |
+
"URL": st.column_config.LinkColumn("π", display_text="π", width="small")
|
| 188 |
}
|
| 189 |
)
|
| 190 |
|