Yep, i understand, but it returns wrong value (and not sorted by date
;-():
("2009-11-11".to_date.."2010-01-01".to_date).each do |date|
exists = result.find { |x| x[:date] == date.to_s }
next if exists
result << {
ositive => "0", :neutral => "0", :total => "0",
:date => date, :negative => "0" }
end
return result
=> [{
ositive=>"0", :neutral=>"2", :total=>"5", :date=>"2009-12-01",
:negative=>"3"}, {
ositive=>"3", :neutral=>"3", :total=>"7",
:date=>"2009-12-08", :negative=>"1"}, {
ositive=>"1", :neutral=>"1",
:total=>"3", :date=>"2009-12-09", :negative=>"1"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Wed, 11 Nov 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Thu, 12 Nov 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Fri, 13 Nov 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Sat, 14 Nov 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Sun, 15 Nov 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Mon, 16 Nov 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Tue, 17 Nov 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Wed, 18 Nov 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Thu, 19 Nov 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Fri, 20 Nov 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Sat, 21 Nov 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Sun, 22 Nov 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Mon, 23 Nov 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Tue, 24 Nov 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Wed, 25 Nov 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Thu, 26 Nov 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Fri, 27 Nov 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Sat, 28 Nov 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Sun, 29 Nov 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Mon, 30 Nov 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Tue, 01 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Wed, 02 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Thu, 03 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Fri, 04 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Sat, 05 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Sun, 06 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Mon, 07 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Tue, 08 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Wed, 09 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Thu, 10 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Fri, 11 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Sat, 12 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Sun, 13 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Mon, 14 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Tue, 15 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Wed, 16 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Thu, 17 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Fri, 18 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Sat, 19 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Sun, 20 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Mon, 21 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Tue, 22 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Wed, 23 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Thu, 24 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Fri, 25 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Sat, 26 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Sun, 27 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Mon, 28 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Tue, 29 Dec 2009, :negative=>"0"},
{
ositive=>"0", :neutral=>"0", :total=>"0", :date=>Wed, 30 Dec 2009,
:negative=>"0"}, {
ositive=>"0", :neutral=>"0", :total=>"0",
:date=>Thu, 31 Dec 2009, :negative=>"0"}, {
ositive=>"0",
:neutral=>"0", :total=>"0", :date=>Fri, 01 Jan 2010, :negative=>"0"}]