'Fills in missing months between earlier occurances and now.
Save format: [(\'YYYY-MM, #), ...]
Example output: [(2010-12, 123), (2011-01, 146)]'

def save_feed_story_history_statistics(self):

    now = datetime.datetime.utcnow()
    min_year = now.year
    total = 0
    month_count = 0
    map_f = '\n                                                function()    {\n                                                                var    date    =    (this.shared_date.getFullYear())    +    "-"    +    (this.shared_date.getMonth()+1);\n                                                                var    hour    =    this.shared_date.getHours();\n                                                                var    day    =    this.shared_date.getDay();\n                                                                emit(this.story_hash,    {\'month\':    date,    \'hour\':    hour,    \'day\':    day});\n                                                }\n                                '
    reduce_f = '\n                                                function(key,    values)    {\n                                                                return    values;\n                                                }\n                                '
    dates = defaultdict(int)
    hours = defaultdict(int)
    days = defaultdict(int)
    results = MSharedStory.objects(user_id=self.user_id).map_reduce(map_f, reduce_f, output='inline')
    for result in results:
        dates[result.value['month']] += 1
        hours[str(int(result.value['hour']))] += 1
        days[str(int(result.value['day']))] += 1
        year = int(re.findall('(\\d{4})-\\d{1,2}', result.value['month'])[0])
        if (year < min_year):
            min_year = year
    months = []
    start = False
    for year in range(min_year, (now.year + 1)):
        for month in range(1, (12 + 1)):
            if (datetime.datetime(year, month, 1) < now):
                key = (u'%s-%s' % (year, month))
                if (dates.get(key) or start):
                    start = True
                    months.append((key, dates.get(key, 0)))
                    total += dates.get(key, 0)
                    month_count += 1
    self.story_count_history = months
    self.story_days_history = days
    self.story_hours_history = hours
    self.average_stories_per_month = (total / max(1, month_count))
    self.save()
