aggregated_feed Package¶
aggregated_feed
Package¶
base
Module¶
-
class
stream_framework.feeds.aggregated_feed.base.
AggregatedFeed
(user_id)[source]¶ Bases:
stream_framework.feeds.base.BaseFeed
Aggregated feeds are an extension of the basic feed. They turn activities into aggregated activities by using an aggregator class.
See
BaseAggregator
You can use aggregated feeds to built smart feeds, such as Facebook’s newsfeed. Alternatively you can also use smart feeds for building complex notification systems.
Have a look at fashiolista.com for the possibilities.
Note
Aggregated feeds do more work in the fanout phase. Remember that for every user activity the number of fanouts is equal to their number of followers. So with a 1000 user activities, with an average of 500 followers per user, you already end up running 500.000 fanout operations
Since the fanout operation happens so often, you should make sure not to do any queries in the fanout phase or any other resource intensive operations.
Aggregated feeds differ from feeds in a few ways:
- Aggregator classes aggregate activities into aggregated activities
- We need to update aggregated activities instead of only appending
- Serialization is different
-
add_many
(activities, trim=True, current_activities=None, *args, **kwargs)[source]¶ Adds many activities to the feed
Unfortunately we can’t support the batch interface. The writes depend on the reads.
Also subsequent writes will depend on these writes. So no batching is possible at all.
Parameters: activities – the list of activities
-
add_many_aggregated
(aggregated, *args, **kwargs)[source]¶ Adds the list of aggregated activities
Parameters: aggregated – the list of aggregated activities to add
-
aggregated_activity_class
¶ alias of
AggregatedActivity
-
aggregator_class
¶ alias of
RecentVerbAggregator
-
contains
(activity)[source]¶ Checks if the activity is present in any of the aggregated activities
Parameters: activity – the activity to search for
-
merge_max_length
= 20¶
-
remove_many
(activities, batch_interface=None, trim=True, *args, **kwargs)[source]¶ Removes many activities from the feed
Parameters: activities – the list of activities to remove
-
remove_many_aggregated
(aggregated, *args, **kwargs)[source]¶ Removes the list of aggregated activities
Parameters: aggregated – the list of aggregated activities to remove
-
timeline_serializer
¶ alias of
AggregatedActivitySerializer