Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Add 90 days as a time filter option
Browse files Browse the repository at this point in the history
  • Loading branch information
joshenlim committed Jan 5, 2021
1 parent 2289d43 commit 2c689e6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/TimelineChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import { convertCumulativeToDailyNewStars } from '~/lib/helpers'

const oneWeek = 7*24*60*60*1000
const oneMonth = 30*24*60*60*1000
const ninetyDays = 90*24*60*60*1000

const options = [
{
key: 'allTime',
label: 'All time'
},
{
key: 'pastNinetyDays',
label: 'Past 90 days'
},
{
key: 'pastMonth',
label: 'Past month'
Expand Down Expand Up @@ -69,6 +74,11 @@ const TimelineChart = ({
filteredData = filteredData.filter(row => {
if (row[dateKey] >= pastMonth.toISOString() ) return row
})
} else if (selectedTimeFilter === 'pastNinetyDays') {
const pastNinetyDays = new Date(currentTime - ninetyDays)
filteredData = filteredData.filter(row => {
if (row[dateKey] >= pastNinetyDays.toISOString() ) return row
})
}

const sortedData = filteredData.sort((a, b) => {
Expand Down

1 comment on commit 2c689e6

@vercel
Copy link

@vercel vercel bot commented on 2c689e6 Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.