Fixing dates on river blurblog. Also fixing refreshing on friends dialog.

This commit is contained in:
Samuel Clay 2012-08-07 23:55:03 -07:00
parent 2d5f3384db
commit 4fb6e67617
3 changed files with 30 additions and 20 deletions

View file

@ -747,8 +747,11 @@ class MSocialSubscription(mongo.Document):
unread_ranked_stories_keys = 'zU:%s' % (user_id)
if offset and r.exists(unread_ranked_stories_keys):
story_guids = range_func(unread_ranked_stories_keys, offset, limit)
return story_guids
story_guids = range_func(unread_ranked_stories_keys, offset, limit, withscores=True)
if story_guids:
return zip(*story_guids)
else:
return [], []
else:
r.delete(unread_ranked_stories_keys)
@ -760,10 +763,13 @@ class MSocialSubscription(mongo.Document):
if story_guids:
r.zadd(unread_ranked_stories_keys, **dict(story_guids))
story_guids = range_func(unread_ranked_stories_keys, offset, limit)
story_guids = range_func(unread_ranked_stories_keys, offset, limit, withscores=True)
r.expire(unread_ranked_stories_keys, 24*60*60)
return story_guids
if story_guids:
return zip(*story_guids)
else:
return [], []
def mark_story_ids_as_read(self, story_ids, feed_id, request=None):
data = dict(code=0, payload=story_ids)

View file

@ -183,7 +183,7 @@ def load_social_stories(request, user_id, username=None):
@json.json_view
def load_river_blurblog(request):
limit = 12
limit = 10
start = time.time()
user = get_user(request)
social_user_ids = [int(uid) for uid in request.REQUEST.getlist('social_user_ids') if uid]
@ -205,12 +205,13 @@ def load_river_blurblog(request):
offset = (page-1) * limit
limit = page * limit - 1
story_ids = MSocialSubscription.feed_stories(user.pk, social_user_ids,
story_ids, story_dates = MSocialSubscription.feed_stories(user.pk, social_user_ids,
offset=offset, limit=limit,
order=order, read_filter=read_filter)
story_date_order = "%sstory_date" % ('' if order == 'oldest' else '-')
mstories = MStory.objects(id__in=story_ids).order_by(story_date_order)
mstories = MStory.objects(id__in=story_ids)
stories = Feed.format_stories(mstories)
for s, story in enumerate(stories):
story['story_date'] = datetime.datetime.fromtimestamp(story_dates[s])
stories, user_profiles = MSharedStory.stories_with_comments_and_profiles(stories, relative_user_id,
check_all=True)

View file

@ -4,7 +4,6 @@ NEWSBLUR.ReaderFriends = function(options) {
};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.assets;
this.runner();
};
@ -71,8 +70,8 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
fetch_friends: function(callback) {
$('.NB-modal-loading', this.$modal).addClass('NB-active');
this.model.fetch_friends(_.bind(function(data) {
this.profile = this.model.user_profile;
NEWSBLUR.assets.fetch_friends(_.bind(function(data) {
this.profile = NEWSBLUR.assets.user_profile.clone();
this.services = data.services;
this.autofollow = data.autofollow;
this.recommended_users = data.recommended_users;
@ -86,10 +85,14 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
},
check_services_sync_status: function() {
this.model.fetch_friends(_.bind(function(data) {
this.profile = this.model.user_profile;
NEWSBLUR.assets.fetch_friends(_.bind(function(data) {
this.profile = NEWSBLUR.assets.user_profile;
this.services = data.services;
this.make_find_friends_and_services();
if (!this.services['twitter'].syncing && !this.services['facebook'].syncing) {
this.make_find_friends_and_services();
} else {
_.delay(_.bind(this.check_services_sync_status, this), 3000);
}
}, this));
},
@ -192,7 +195,7 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
'.'
]);
$tab.append($heading);
this.model.follower_profiles.each(_.bind(function(profile) {
NEWSBLUR.assets.follower_profiles.each(_.bind(function(profile) {
$tab.append(new NEWSBLUR.Views.SocialProfileBadge({model: profile}));
}, this));
}
@ -210,7 +213,7 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
'.'
]);
$tab.append($heading);
this.model.following_profiles.each(_.bind(function(profile) {
NEWSBLUR.assets.following_profiles.each(_.bind(function(profile) {
$tab.append(new NEWSBLUR.Views.SocialProfileBadge({model: profile}));
}, this));
}
@ -280,7 +283,7 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
disconnect: function(service) {
var $service = $('.NB-friends-service-'+service, this.$modal);
$('.NB-friends-service-connect', $service).text('Disconnecting...');
this.model.disconnect_social_service(service, _.bind(function(data) {
NEWSBLUR.assets.disconnect_social_service(service, _.bind(function(data) {
this.services = data.services;
this.make_find_friends_and_services();
this.make_profile_section();
@ -300,7 +303,7 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
this.fetch_friends();
}
this.model.preference('has_found_friends', true);
NEWSBLUR.assets.preference('has_found_friends', true);
NEWSBLUR.reader.check_hide_getting_started();
},
@ -321,7 +324,7 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
$loading.addClass('NB-active');
this.model.search_for_friends(query, _.bind(function(data) {
NEWSBLUR.assets.search_for_friends(query, _.bind(function(data) {
$loading.removeClass('NB-active');
if (!data || !data.profiles || !data.profiles.length) {
$badges.html($.make('div', {
@ -390,7 +393,7 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
$.targetIs(e, { tagSelector: '.NB-friends-autofollow-checkbox' }, function($t, $p) {
e.preventDefault();
self.model.preference('autofollow_friends', $t.is(':checked'));
NEWSBLUR.assets.preference('autofollow_friends', $t.is(':checked'));
});
},