Skip to content

Commit

Permalink
api: show 52 weeks
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Sep 28, 2023
1 parent ff198a5 commit 9a653df
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ func (a *api) handleGetWeb3Index(c jape.Context) {
}
resp.Revenue.NinetyDaysAgo = revenue.Revenue.USD

y, m, _ := now.Date()
start := time.Date(y-2, m, 1, 0, 0, 0, 0, now.Location())
end := now.AddDate(0, 0, 1)
start := now.AddDate(-1, 0, 0)
start = start.AddDate(0, 0, -int(start.Weekday()+1))
end := now.AddDate(0, 0, int(7-now.Weekday()))

days, err := a.sp.Periods(start, end, stats.PeriodDaily)
if err != nil {
Expand All @@ -175,6 +175,9 @@ func (a *api) handleGetWeb3Index(c jape.Context) {

for i := len(days) - 1; i > 0; i-- {
current, prev := days[i], days[i-1]
if current.Timestamp.After(time.Now()) {
continue
}
resp.Days = append(resp.Days, Web3IndexDay{
Date: current.Timestamp.Unix(),
Revenue: current.Revenue.USD - prev.Revenue.USD,
Expand Down

0 comments on commit 9a653df

Please sign in to comment.