def handle(self, *args, **kwargs): if default_connection.ping() is None: print 'Redis is unavailable.' return start = time.time() qs = Video.objects.all()[:1000] print '"View" videos' i = 0 for video in qs: i += 1 if i % 100 == 0: print 'Viewed %s' % i st_widget_view_statistic.update(video=video) print '' print 'Migrate to DB' st_widget_view_statistic.migrate(verbosity=2) print 'Test migrated data' for video in qs: views_st = st_widget_view_statistic.get_views(video=video) assert video.widget_views_count >= views_st['month'], video.pk print time.time() - start