Skip to content

Commit

Permalink
feat(generators): add generateOrderedDayCounts function
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Jun 10, 2021
1 parent 23d569c commit fbcadd7
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/generators/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,26 @@ export const generateCountriesPopulation = (size: number) => {
}))
}

export const generateDayCounts = (from: Date, to: Date, maxSize = 0.9) => {
export const generateOrderedDayCounts = (from: Date, to: Date) => {
const days = timeDays(from, to)
const dayFormat = timeFormat('%Y-%m-%d')

return days.map(day => {
return {
value: Math.round(Math.random() * 400),
day: dayFormat(day),
}
})
}

export const generateDayCounts = (from: Date, to: Date, maxSize = 0.9) => {
const days = generateOrderedDayCounts(from, to)

const size =
Math.round(days.length * (maxSize * 0.4)) +
Math.round(Math.random() * (days.length * (maxSize * 0.6)))

const dayFormat = timeFormat('%Y-%m-%d')

return shuffle(days)
.slice(0, size)
.map(day => {
return {
day: dayFormat(day),
value: Math.round(Math.random() * 400),
}
})
return shuffle(days).slice(0, size)
}

export const generateCountriesData = (
Expand Down

0 comments on commit fbcadd7

Please sign in to comment.