0

I have a products model and an iTunes sales model. At the moment i'm fairly successfully reporting sales through scopes and ordered hashes. One flaw in the approach i've taken is that if there's no sales for a particular date I don't get a zero entry, just a gap for that date, which proves to be an issue when using something like Highcharts to plot the results.

I'm also soon to add new models for sales data from other sources, which will mean a rewrite to pull these figures into the product view and with my current approach I can see this being a complete headache when one report contains sales for a date but another doesn't.

I'm thinking I should instead for any given product be producing a range of dates (last 30 days for example) and then for those dates bring in the associated sales from my iTunes and other sales models. I'm just not sure how to approach this or if this is even the best approach to take.

Does anyone have experience of building something similar that can offer some guidance here please?

Thanks in advance!

4

1 回答 1

0

这可能不是“正确的方式”,但您始终可以通过数据库中的日期查找表并在其上留下连接。这样,您可以确保查询结果中存在问题期间的所有日期,无论它们是否有数据。

于 2013-04-09T22:31:02.333 回答