nataliaElv commited on
Commit
086fa02
1 Parent(s): ce9dcbc

Cache data

Browse files
Files changed (2) hide show
  1. app.py +24 -25
  2. issues.json +0 -0
app.py CHANGED
@@ -35,24 +35,23 @@ def fetch_data():
35
  )
36
  return pd.DataFrame(issues_data)
37
 
38
- def save_data(df):
39
- df.to_json("issues.json", orient="records", indent=4, index=False)
40
 
41
- @st.cache_data
42
- def load_data():
43
- try:
44
- df = pd.read_json("issues.json", convert_dates=["Created at", "Closed at", "Last update"], date_unit="ms")
45
- except:
46
- df = fetch_data()
47
- 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()
55
-
56
  today = datetime.date.today()
57
 
58
  # Section 1: Issue activity metrics
@@ -97,9 +96,9 @@ st.subheader("Latest updates 📝")
97
  col1, col2 = st.columns(2)
98
  with col1:
99
  last_update_date = st.date_input("Last updated after:", value=today - datetime.timedelta(days=7), format="DD-MM-YYYY")
100
- last_update_date = datetime.datetime.combine(last_update_date, datetime.datetime.min.time()) # Convert to datetime object
101
  with col2:
102
- updated_issues = open_issues[open_issues["Last update"] > last_update_date]
103
  st.metric("Results:", updated_issues.shape[0])
104
 
105
  st.dataframe(
@@ -118,9 +117,9 @@ st.subheader("Stale issues? 🕸️")
118
  col1, col2 = st.columns(2)
119
  with col1:
120
  not_updated_since = st.date_input("Not updated since:", value=today - datetime.timedelta(days=90), format="DD-MM-YYYY")
121
- not_updated_since = datetime.datetime.combine(not_updated_since, datetime.datetime.min.time()) # Convert to datetime object
122
  with col2:
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),
@@ -198,10 +197,10 @@ st.dataframe(
198
  # st.header("Issue dependencies")
199
  # ## Map: dependencies between issues. Network of issue mentions.x
200
 
201
- status.update(label="Checking for updated data...", state="running")
202
- updated_data = fetch_data()
203
- if df.equals(updated_data):
204
- status.update(label="Data is up to date!", state="complete")
205
- else:
206
- save_data(updated_data)
207
- status.update(label="Refresh for updated data!", state="complete")
 
35
  )
36
  return pd.DataFrame(issues_data)
37
 
38
+ # def save_data(df):
39
+ # df.to_json("issues.json", orient="records", indent=4, index=False)
40
 
41
+ # @st.cache_data
42
+ # def load_data():
43
+ # try:
44
+ # df = pd.read_json("issues.json", convert_dates=["Created at", "Closed at", "Last update"], date_unit="ms")
45
+ # except:
46
+ # df = fetch_data()
47
+ # save_data(df)
48
+ # return df
49
 
50
 
51
  st.title(f"GitHub Issues Dashboard")
52
+ with st.status(label="Loading data...", state="running") as status:
53
+ df = fetch_data()
54
+ status.update(label="Data loaded!", state="complete")
 
55
  today = datetime.date.today()
56
 
57
  # Section 1: Issue activity metrics
 
96
  col1, col2 = st.columns(2)
97
  with col1:
98
  last_update_date = st.date_input("Last updated after:", value=today - datetime.timedelta(days=7), format="DD-MM-YYYY")
99
+ last_update_date = datetime.datetime.combine(last_update_date, datetime.datetime.min.time())
100
  with col2:
101
+ updated_issues = open_issues[pd.to_datetime(open_issues["Last update"]).dt.tz_localize(None) > pd.to_datetime(last_update_date)]
102
  st.metric("Results:", updated_issues.shape[0])
103
 
104
  st.dataframe(
 
117
  col1, col2 = st.columns(2)
118
  with col1:
119
  not_updated_since = st.date_input("Not updated since:", value=today - datetime.timedelta(days=90), format="DD-MM-YYYY")
120
+ not_updated_since = datetime.datetime.combine(not_updated_since, datetime.datetime.min.time())
121
  with col2:
122
+ stale_issues = open_issues[pd.to_datetime(open_issues["Last update"]).dt.tz_localize(None) < pd.to_datetime(not_updated_since)]
123
  st.metric("Results:", stale_issues.shape[0])
124
  st.dataframe(
125
  stale_issues[["Issue","Labels", "Repository", "Last update","URL"]].sort_values(by="Last update", ascending=True),
 
197
  # st.header("Issue dependencies")
198
  # ## Map: dependencies between issues. Network of issue mentions.x
199
 
200
+ # status.update(label="Checking for updated data...", state="running")
201
+ # updated_data = fetch_data()
202
+ # if df.equals(updated_data):
203
+ # status.update(label="Data is up to date!", state="complete")
204
+ # else:
205
+ # save_data(updated_data)
206
+ # status.update(label="Refresh for updated data!", state="complete")
issues.json DELETED
The diff for this file is too large to render. See raw diff