Skip to content

Commit

Permalink
Launching search (quietly).
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelclay committed Apr 23, 2014
1 parent 4fe9a7d commit de4e641
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
3 changes: 1 addition & 2 deletions apps/reader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,7 @@ def load_single_feed(request, feed_id):
if user.profile.is_premium:
user_search = MUserSearch.get_user(user.pk)
user_search.touch_search_date()
blackout = not user.is_staff
stories = feed.find_stories(query, order=order, offset=offset, limit=limit, blackout=blackout)
stories = feed.find_stories(query, order=order, offset=offset, limit=limit)
else:
stories = []
message = "You must be a premium subscriber to search."
Expand Down
20 changes: 6 additions & 14 deletions apps/rss_feeds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,20 +1218,12 @@ def find_feed_stories(cls, feed_ids, query, order="newest", offset=0, limit=25):

return stories

def find_stories(self, query, order="newest", offset=0, limit=25, blackout=True):
if blackout:
stories_db = MStory.objects(
Q(story_feed_id=self.pk) &
(Q(story_title__icontains=query) |
Q(story_author_name__icontains=query) |
Q(story_tags__icontains=query))
).order_by('-story_date' if order == "newest" else 'story_date')[offset:offset+limit]
else:
story_ids = SearchStory.query(feed_ids=[self.pk], query=query, order=order,
offset=offset, limit=limit)
stories_db = MStory.objects(
story_hash__in=story_ids
).order_by('-story_date' if order == "newest" else 'story_date')
def find_stories(self, query, order="newest", offset=0, limit=25):
story_ids = SearchStory.query(feed_ids=[self.pk], query=query, order=order,
offset=offset, limit=limit)
stories_db = MStory.objects(
story_hash__in=story_ids
).order_by('-story_date' if order == "newest" else 'story_date')

stories = self.format_stories(stories_db, self.pk)

Expand Down
7 changes: 3 additions & 4 deletions apps/search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ def get_user(cls, user_id):
return user_search

def touch_search_date(self):
# Blackout
# if not self.subscriptions_indexed and not self.subscriptions_indexing:
# self.schedule_index_subscriptions_for_search()
# self.subscriptions_indexing = True
if not self.subscriptions_indexed and not self.subscriptions_indexing:
self.schedule_index_subscriptions_for_search()
self.subscriptions_indexing = True

self.last_search_date = datetime.datetime.now()
self.save()
Expand Down
1 change: 0 additions & 1 deletion media/js/newsblur/views/feed_search_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ NEWSBLUR.Views.FeedSearchView = Backbone.View.extend({
},

render: function() {
// if (!NEWSBLUR.Globals.is_staff) return this;
if (NEWSBLUR.app.active_search) {
NEWSBLUR.app.active_search.blur_search();
NEWSBLUR.app.active_search.remove();
Expand Down
2 changes: 0 additions & 2 deletions media/js/newsblur/views/folder_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ NEWSBLUR.Views.Folder = Backbone.View.extend({

if (this.options.feedbar) {
this.show_collapsed_folder_count();
}
if (this.options.feedbar && NEWSBLUR.Globals.is_staff) {
this.search_view = new NEWSBLUR.Views.FeedSearchView({
feedbar_view: this
}).render();
Expand Down

0 comments on commit de4e641

Please sign in to comment.