Spaces:
Build error
Build error
nataliaElv commited on
Commit ·
9b1266b
1
Parent(s): 58bba8c
Allow multiple repos
Browse files
app.py
CHANGED
|
@@ -7,29 +7,32 @@ import re
|
|
| 7 |
import datetime
|
| 8 |
|
| 9 |
g = Github(st.secrets["ACCESS_TOKEN"])
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
@st.cache_data
|
| 13 |
def fetch_data():
|
| 14 |
|
| 15 |
issues_data = []
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
return pd.DataFrame(issues_data)
|
| 34 |
|
| 35 |
def save_data(df):
|
|
@@ -45,7 +48,7 @@ def load_data():
|
|
| 45 |
return df
|
| 46 |
|
| 47 |
|
| 48 |
-
st.title(f"GitHub Issues Dashboard
|
| 49 |
status = st.status(label="Loading data...", state="running")
|
| 50 |
|
| 51 |
df = load_data()
|
|
@@ -100,7 +103,7 @@ with col2:
|
|
| 100 |
st.metric("Results:", updated_issues.shape[0])
|
| 101 |
|
| 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={
|
|
@@ -120,7 +123,7 @@ with col2:
|
|
| 120 |
stale_issues = open_issues[open_issues["Last update"] < not_updated_since]
|
| 121 |
st.metric("Results:", stale_issues.shape[0])
|
| 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={
|
|
@@ -138,20 +141,20 @@ col1, col2 = st.columns(2)
|
|
| 138 |
## Dataframe: Number of open issues by label.
|
| 139 |
with col1:
|
| 140 |
st.subheader("Top ten labels 🔖")
|
| 141 |
-
|
| 142 |
-
label_counts = open_issues_exploded.value_counts("Labels").to_frame()
|
| 143 |
|
| 144 |
-
def generate_labels_link(labels):
|
| 145 |
links = []
|
| 146 |
-
for label in labels:
|
| 147 |
label = label.replace(" ", "+")
|
| 148 |
-
links.append(f"https://github.com/argilla-io/
|
| 149 |
return links
|
| 150 |
|
| 151 |
-
label_counts['Link'] = generate_labels_link(label_counts
|
| 152 |
|
| 153 |
st.dataframe(
|
| 154 |
-
label_counts.head(10),
|
|
|
|
| 155 |
column_config={
|
| 156 |
"Labels": st.column_config.TextColumn("Labels"),
|
| 157 |
"count": st.column_config.NumberColumn("Count"),
|
|
@@ -175,7 +178,7 @@ st.header("Community engagement")
|
|
| 175 |
# ## Dataframe: Latest issues open by the community
|
| 176 |
# ## Dataframe: issues sorted by number of comments
|
| 177 |
st.subheader("Top engaging issues 💬")
|
| 178 |
-
engagement_df = open_issues[["Issue","Reactions","Comments","URL"]].sort_values(by=["Reactions", "Comments"], ascending=False).head(10)
|
| 179 |
st.dataframe(
|
| 180 |
engagement_df,
|
| 181 |
hide_index=True,
|
|
|
|
| 7 |
import datetime
|
| 8 |
|
| 9 |
g = Github(st.secrets["ACCESS_TOKEN"])
|
| 10 |
+
repos = st.secrets["REPO_NAME"].split(",")
|
| 11 |
+
repos = [g.get_repo(repo) for repo in repos]
|
| 12 |
|
| 13 |
@st.cache_data
|
| 14 |
def fetch_data():
|
| 15 |
|
| 16 |
issues_data = []
|
| 17 |
|
| 18 |
+
for repo in repos:
|
| 19 |
+
issues = repo.get_issues(state="all")
|
| 20 |
+
|
| 21 |
+
for issue in issues:
|
| 22 |
+
issues_data.append(
|
| 23 |
+
{
|
| 24 |
+
'Issue': f"{issue.number} - {issue.title}",
|
| 25 |
+
'State': issue.state,
|
| 26 |
+
'Created at': issue.created_at,
|
| 27 |
+
'Closed at': issue.closed_at,
|
| 28 |
+
'Last update': issue.updated_at,
|
| 29 |
+
'Labels': [label.name for label in issue.labels],
|
| 30 |
+
'Reactions': issue.reactions['total_count'],
|
| 31 |
+
'Comments': issue.comments,
|
| 32 |
+
'URL': issue.html_url,
|
| 33 |
+
'Repository': repo.name,
|
| 34 |
+
}
|
| 35 |
+
)
|
| 36 |
return pd.DataFrame(issues_data)
|
| 37 |
|
| 38 |
def save_data(df):
|
|
|
|
| 48 |
return df
|
| 49 |
|
| 50 |
|
| 51 |
+
st.title(f"GitHub Issues Dashboard")
|
| 52 |
status = st.status(label="Loading data...", state="running")
|
| 53 |
|
| 54 |
df = load_data()
|
|
|
|
| 103 |
st.metric("Results:", updated_issues.shape[0])
|
| 104 |
|
| 105 |
st.dataframe(
|
| 106 |
+
updated_issues[["Issue","Labels", "Repository", "Last update","URL"]].sort_values(by="Last update", ascending=False),
|
| 107 |
hide_index=True,
|
| 108 |
# use_container_width=True,
|
| 109 |
column_config={
|
|
|
|
| 123 |
stale_issues = open_issues[open_issues["Last update"] < not_updated_since]
|
| 124 |
st.metric("Results:", stale_issues.shape[0])
|
| 125 |
st.dataframe(
|
| 126 |
+
stale_issues[["Issue","Labels", "Repository", "Last update","URL"]].sort_values(by="Last update", ascending=True),
|
| 127 |
hide_index=True,
|
| 128 |
# use_container_width=True,
|
| 129 |
column_config={
|
|
|
|
| 141 |
## Dataframe: Number of open issues by label.
|
| 142 |
with col1:
|
| 143 |
st.subheader("Top ten labels 🔖")
|
| 144 |
+
label_counts = open_issues.groupby("Repository").apply(lambda x: x.explode("Labels").value_counts("Labels").to_frame().reset_index()).reset_index()
|
|
|
|
| 145 |
|
| 146 |
+
def generate_labels_link(labels,repos):
|
| 147 |
links = []
|
| 148 |
+
for label,repo in zip(labels,repos):
|
| 149 |
label = label.replace(" ", "+")
|
| 150 |
+
links.append(f"https://github.com/argilla-io/{repo}/issues?q=is:open+is:issue+label:%22{label}%22")
|
| 151 |
return links
|
| 152 |
|
| 153 |
+
label_counts['Link'] = generate_labels_link(label_counts['Labels'],label_counts['Repository'])
|
| 154 |
|
| 155 |
st.dataframe(
|
| 156 |
+
label_counts[["Labels","Repository", "count","Link"]].head(10),
|
| 157 |
+
hide_index=True,
|
| 158 |
column_config={
|
| 159 |
"Labels": st.column_config.TextColumn("Labels"),
|
| 160 |
"count": st.column_config.NumberColumn("Count"),
|
|
|
|
| 178 |
# ## Dataframe: Latest issues open by the community
|
| 179 |
# ## Dataframe: issues sorted by number of comments
|
| 180 |
st.subheader("Top engaging issues 💬")
|
| 181 |
+
engagement_df = open_issues[["Issue","Repository","Reactions","Comments","URL"]].sort_values(by=["Reactions", "Comments"], ascending=False).head(10)
|
| 182 |
st.dataframe(
|
| 183 |
engagement_df,
|
| 184 |
hide_index=True,
|