Skip to content

Commit

Permalink
Merge pull request #3 from pmbrull/feature/daily-stars
Browse files Browse the repository at this point in the history
Daily stars instead of weekly
  • Loading branch information
pmbrull authored Apr 3, 2022
2 parents d00e789 + 90abbb9 commit 20df10f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions openstats/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def stars_component(self):
Prepare the graph to show the stars evolution
and the differences
"""
df = self.data.stars_data().reset_index(level=0)
df = self.data.stars_data()

if df is not None and not df.empty:
current = int(df.iloc[-1].get("stars"))
last_week = int(df.iloc[-2].get("stars"))
last_month = int(df.iloc[-4].get("stars"))
last_week = int(df.iloc[-7].get("stars"))
last_month = int(df.iloc[-30].get("stars"))

else:
st.write("Error fetching Star data")
Expand Down
3 changes: 2 additions & 1 deletion openstats/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def stars_data(self) -> Optional[DataFrame]:
)

df["date"] = pd.to_datetime(df["date"])
df = df.resample("W", on="date")[["stars"]].sum()
# This resample groups by week. Let's keep grouping by day.
# df = df.resample("W", on="date")[["stars"]].sum()
df["stars"] = df["stars"].cumsum()

return df
Expand Down

0 comments on commit 20df10f

Please sign in to comment.