I’m stumped. Would love help thinking how to structure this. The answer might involve a plugin.
I have a bar chart, and I want to show 7 bars for each day of the week for the most recent 7 days. I have the plugin, I just need to give it the right list of numbers.
The values from those 7 days are given by an object Summary Stat. Summary Stat has these fields
- Day - formatted as text e.g., Monday April 17th
- Day - formatted as timestamp
- Total Time Asleep
- Child
- …
Each Child has a list of Summary Stats, so they’re linked together in both directions. I want the chart to show a Child’s Total Time Asleep for each of the last 7 days. So normally, I’d use Child’s List of Summary Stat’s:filtered to the last 7 days. But the problem is that a child won’t necessarily have Summary Stats for each of the last 7 days. They might have ones only for Tuesday, Wedesday, and Friday. So I want the list of numbers going to the chart to have 0’s on days for which there were no Summary Stats. E.g., the list might be (0, 0, 10, 8.5, 0, 11, 0). But I don’t know how to generate that list with the zeroes. For each day in the last 7 days, I want to check whether a Summary Stat exists for that child, and if so, take the first item’s Total Time Asleep. If not, make it 0.
I’ve been using a solution where I just automatically generate lots of Summary Stats with 0s so every child has a Summary Stat for every day. But it’s bloating my dB with tons of empty Summary Stats, and causing other annoying problems. I’d rather have something more efficient.
Can anyone help me think this through?