nataliaElv commited on
Commit
b1dec7c
Β·
1 Parent(s): 0dca33a

First draft

Browse files
Files changed (2) hide show
  1. app.py +100 -9
  2. issues.json +0 -0
app.py CHANGED
@@ -2,16 +2,107 @@ import streamlit as st
2
  import pandas as pd
3
  from github import Github
4
  from datetime import datetime, timedelta
 
5
 
6
- def get_issues(state):
7
- g = Github(st.secrets["ACCESS_TOKEN"])
8
- repo = g.get_repo(st.secrets["REPO_NAME"])
9
- issues = repo.get_issues(state=state)
10
- return issues
11
 
 
12
 
13
- open_issues = get_issues(state="open")
14
- st.metric("Open Issues", open_issues.totalCount)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- closed_issues = get_issues(state="closed", type="issue")
17
- st.metric("Closed Issues", closed_issues.totalCount)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import pandas as pd
3
  from github import Github
4
  from datetime import datetime, timedelta
5
+ import time
6
 
7
+ g = Github(st.secrets["ACCESS_TOKEN"])
8
+ repo = g.get_repo(st.secrets["REPO_NAME"])
 
 
 
9
 
10
+ def fetch_data():
11
 
12
+ issues_data = []
13
+
14
+ issues = repo.get_issues(state="all")
15
+
16
+ for issue in issues:
17
+ issues_data.append(
18
+ {
19
+ 'Number': issue.number,
20
+ 'Title': issue.title,
21
+ 'State': issue.state,
22
+ 'Created at': issue.created_at,
23
+ 'Closed at': issue.closed_at,
24
+ 'Labels': [label.name for label in issue.labels],
25
+ 'Reactions': issue.reactions['total_count'],
26
+ 'Comments': issue.comments,
27
+ 'URL': issue.html_url
28
+ }
29
+ )
30
+ return pd.DataFrame(issues_data)
31
 
32
+ def save_data(df):
33
+ df.to_json("issues.json", orient="records", indent=4, index=False)
34
+
35
+
36
+ st.title(f"GitHub Issues Dashboard for {repo.name}")
37
+
38
+ fetching_data = st.empty()
39
+
40
+ df = pd.read_json("issues.json")
41
+
42
+ status = st.status("Loading data...", status="running")
43
+
44
+ # Section 1: Issue activity metrics
45
+ st.header("Issue activity metrics")
46
+
47
+ col1, col2 = st.columns(2)
48
+
49
+ state_counts = df['State'].value_counts()
50
+ open_issues = df.loc[df['State'] == 'open']
51
+
52
+ with col1:
53
+ st.metric(label="Open Issues", value=state_counts['open'])
54
+
55
+ with col2:
56
+ st.metric(label="Closed Issues", value=state_counts['closed'])
57
+
58
+
59
+ # # TODO Plot: number of open vs closed issues by date
60
+
61
+ # # TODO Dataframe: Unresolved conversations
62
+ # ## Issues with new comments. Sorted by number of new comments (based on timeframe above) and/or date of last comment.
63
+
64
+ # Section 2: Issue classification
65
+ st.header("Issue classification")
66
+
67
+ ## Dataframe: Number of open issues by label.
68
+ st.subheader("Top ten labels by number of open issues:")
69
+ open_issues_exploded = open_issues.explode("Labels")
70
+ label_counts = open_issues_exploded.value_counts("Labels")
71
+ st.dataframe(label_counts.head(10))
72
+
73
+ # ## Dataframe: Number of open bugs by severity level. Critical, major, minor
74
+ # ## Cloud of words: Issue titles and description
75
+
76
+ # # Community engagement
77
+ st.header("Community engagement")
78
+ # ## Dataframe: Latest issues open by the community
79
+ # ## Dataframe: issues sorted by number of comments
80
+ engagement_df = df[["Number","Title","Reactions","Comments","URL"]].sort_values(by=["Reactions", "Comments"], ascending=False).head(10)
81
+ st.dataframe(
82
+ engagement_df,
83
+ hide_index=True,
84
+ use_container_width=True,
85
+ column_config={
86
+ "Number": st.column_config.NumberColumn("No."),
87
+ "Title": st.column_config.TextColumn("Title"),
88
+ "Reactions": st.column_config.NumberColumn("Reactions", format="%d πŸ‘"),
89
+ "Comments": st.column_config.NumberColumn("Comments", format="%d πŸ’¬"),
90
+ "URL": st.column_config.LinkColumn("πŸ”—", display_text="πŸ”—")
91
+ }
92
+ )
93
+
94
+ # ## Cloud of words: Comments??
95
+ # ## Dataframe: issues sorted by number of reactions.
96
+ # ## Dataframe: Contributor leaderboard.
97
+
98
+ # # Issue dependencies
99
+ # st.header("Issue dependencies")
100
+ # ## Map: dependencies between issues. Network of issue mentions.x
101
+
102
+ status.update(label="Checking for updated data...", status="running")
103
+ updated_data = fetch_data()
104
+ if not df.equals(updated_data):
105
+ save_data(updated_data)
106
+ status.update(label="Refresh for updated data!", status="complete")
107
+ else:
108
+ status.update(label="Data is up to date!", status="complete")
issues.json ADDED
The diff for this file is too large to render. See raw diff