Пример #1
0
    def test_aggregated_add_many(self):
        # setup the pins and activity chunk
        t = timer()
        admin_user_id = 1
        aggregated = feedly.get_feeds(admin_user_id)['aggregated']
        pins = list(Pin.objects.filter(user=admin_user_id)[:3])
        activities = []
        base_activity = pins[0].create_activity()
        sample_size = 1000
        for x in range(1, sample_size):
            activity = copy.deepcopy(base_activity)
            activity.actor_id = x
            activity.object_id = x
            activities.append(activity)

        print 'running on %s' % settings.FEEDLY_CASSANDRA_HOSTS
        print 'inserting the many'
        aggregated.insert_activities(activities)
        print 'done, took %s' % t.next()

        for activity in activities:
            aggregated.add_many([activity], trim=False)
        add_many_time = t.next()
        print 'add many ran 10000 times, took %s' % add_many_time
        popular_user_time = 100000. / sample_size * add_many_time
        print 'popular user fanout would take %s seconds' % popular_user_time
Пример #2
0
    def setUp(self):
        TestCase.setUp(self)

        self.bogus_user = bogus_user = get_user_model().objects.get(
            username='******')
        self.bogus_user2 = bogus_user2 = get_user_model().objects.get(
            username='******')
        # start by resetting the feeds
        for u in [self.bogus_user, self.bogus_user2]:
            user_feed = feedly.get_user_feed(u.id)
            user_feed.delete()
            for name, feed in feedly.get_feeds(u.id).items():
                feed.delete()

        # login the user
        rf = RequestMock()
        self.rf = rf
        self.client = Client()
        self.auth_client = Client()
        self.auth_client2 = Client()
        auth_response = self.auth_client.login(
            username='******', password='******')
        self.assertTrue(auth_response)
        auth_response = self.auth_client2.login(
            username='******', password='******')
        self.assertTrue(auth_response)
Пример #3
0
    def setUp(self):
        TestCase.setUp(self)

        self.bogus_user = bogus_user = get_user_model().objects.get(
            username='******')
        self.bogus_user2 = bogus_user2 = get_user_model().objects.get(
            username='******')
        # start by resetting the feeds
        for u in [self.bogus_user, self.bogus_user2]:
            user_feed = feedly.get_user_feed(u.id)
            user_feed.delete()
            for name, feed in feedly.get_feeds(u.id).items():
                feed.delete()

        # login the user
        rf = RequestMock()
        self.rf = rf
        self.client = Client()
        self.auth_client = Client()
        self.auth_client2 = Client()
        auth_response = self.auth_client.login(username='******',
                                               password='******')
        self.assertTrue(auth_response)
        auth_response = self.auth_client2.login(username='******',
                                                password='******')
        self.assertTrue(auth_response)
Пример #4
0
    def test_aggregated_add_many(self):
        # setup the pins and activity chunk
        t = timer()
        admin_user_id = 1
        aggregated = feedly.get_feeds(admin_user_id)['aggregated']
        pins = list(Pin.objects.filter(user=admin_user_id)[:3])
        activities = []
        base_activity = pins[0].create_activity()
        sample_size = 1000
        for x in range(1, sample_size):
            activity = copy.deepcopy(base_activity)
            activity.actor_id = x
            activity.object_id = x
            activities.append(activity)

        print 'running on %s' % settings.FEEDLY_CASSANDRA_HOSTS
        print 'inserting the many'
        aggregated.insert_activities(activities)
        print 'done, took %s' % t.next()

        for activity in activities:
            aggregated.add_many([activity], trim=False)
        add_many_time = t.next()
        print 'add many ran 10000 times, took %s' % add_many_time
        popular_user_time = 100000. / sample_size * add_many_time
        print 'popular user fanout would take %s seconds' % popular_user_time
Пример #5
0
def aggregated_feed(request):
    """
    Items pinned by the people you follow
    """
    context = RequestContext(request)
    feed = feedly.get_feeds(request.user.id)["aggregated"]
    if request.REQUEST.get("delete"):
        feed.delete()
    activities = list(feed[:25])
    if request.REQUEST.get("raise"):
        raise Exception, activities
    context["feed_pins"] = enrich_aggregated_activities(activities)
    response = render_to_response("core/aggregated_feed.html", context)
    return response
Пример #6
0
def aggregated_feed(request):
    '''
    Items pinned by the people you follow
    '''
    context = RequestContext(request)
    feed = feedly.get_feeds(request.user.id)['aggregated']
    if request.REQUEST.get('delete'):
        feed.delete()
    activities = list(feed[:25])
    if request.REQUEST.get('raise'):
        raise Exception, activities
    context['feed_pins'] = enrich_aggregated_activities(activities)
    response = render_to_response('core/aggregated_feed.html', context)
    return response
Пример #7
0
def aggregated_feed(request):
    '''
    Items pinned by the people you follow
    '''
    context = RequestContext(request)
    feed = feedly.get_feeds(request.user.id)['aggregated']
    if request.REQUEST.get('delete'):
        feed.delete()
    activities = list(feed[:25])
    if request.REQUEST.get('raise'):
        raise Exception, activities
    context['feed_pins'] = enrich_aggregated_activities(activities)
    response = render_to_response('core/aggregated_feed.html', context)
    return response