'Replace the stats for the given period from Google Analytics.'

@classmethod
def reload_period_from_analytics(cls, period, verbose=False):

    counts = googleanalytics.pageviews_by_document(verbose=verbose, *period_dates(period))
    if counts:
        close_old_connections()
        cursor = connection.cursor()
        cursor.execute('DELETE    FROM    `dashboards_wikidocumentvisits`                WHERE    `period`    =    %s', [period])
        for (doc_id, visits) in counts.iteritems():
            cls.objects.create(document=Document(pk=doc_id), visits=visits, period=period)
    else:
        log.warning('Google    Analytics    returned    no    interesting    data,    so    I    kept    what    I    had.')
