summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/models/post.py208
1 files changed, 0 insertions, 208 deletions
diff --git a/askbot/models/post.py b/askbot/models/post.py
index 48abcd49..0474d257 100644
--- a/askbot/models/post.py
+++ b/askbot/models/post.py
@@ -80,214 +80,6 @@ class PostQuerySet(models.query.QuerySet):
# #fallback to dumb title match search
# return self.filter(thread__title__icontains=search_query)
- # def run_advanced_search(
- # self,
- # request_user = None,
- # search_state = None
- # ):
- # """all parameters are guaranteed to be clean
- # however may not relate to database - in that case
- # a relvant filter will be silently dropped
- # """
- # #todo: same as for get_by_text_query - goes to Tread
- # scope_selector = getattr(
- # search_state,
- # 'scope',
- # const.DEFAULT_POST_SCOPE
- # )
- #
- # search_query = search_state.query
- # tag_selector = search_state.tags
- # author_selector = search_state.author
- #
- # import ipdb; ipdb.set_trace()
- #
- # sort_method = getattr(
- # search_state,
- # 'sort',
- # const.DEFAULT_POST_SORT_METHOD
- # )
- # qs = self.filter(deleted=False)#todo - add a possibility to see deleted questions
- #
- # #return metadata
- # meta_data = {}
- # if search_query:
- # if search_state.stripped_query:
- # qs = qs.get_by_text_query(search_state.stripped_query)
- # #a patch for postgres search sort method
- # if askbot.conf.should_show_sort_by_relevance():
- # if sort_method == 'relevance-desc':
- # qs = qs.extra(order_by = ['-relevance',])
- # if search_state.query_title:
- # qs = qs.filter(thread__title__icontains = search_state.query_title)
- # if len(search_state.query_tags) > 0:
- # qs = qs.filter(thread__tags__name__in = search_state.query_tags)
- # if len(search_state.query_users) > 0:
- # query_users = list()
- # for username in search_state.query_users:
- # try:
- # user = User.objects.get(username__iexact = username)
- # query_users.append(user)
- # except User.DoesNotExist:
- # pass
- # if len(query_users) > 0:
- # qs = qs.filter(author__in = query_users)
- #
- # if tag_selector:
- # for tag in tag_selector:
- # qs = qs.filter(thread__tags__name = tag)
- #
- #
- # #have to import this at run time, otherwise there
- # #a circular import dependency...
- # from askbot.conf import settings as askbot_settings
- # if scope_selector:
- # if scope_selector == 'unanswered':
- # qs = qs.filter(thread__closed = False)#do not show closed questions in unanswered section
- # if askbot_settings.UNANSWERED_QUESTION_MEANING == 'NO_ANSWERS':
- # qs = qs.filter(thread__answer_count=0)#todo: expand for different meanings of this
- # elif askbot_settings.UNANSWERED_QUESTION_MEANING == 'NO_ACCEPTED_ANSWERS':
- # qs = qs.filter(thread__accepted_answer__isnull=True) #answer_accepted=False
- # elif askbot_settings.UNANSWERED_QUESTION_MEANING == 'NO_UPVOTED_ANSWERS':
- # raise NotImplementedError()
- # else:
- # raise Exception('UNANSWERED_QUESTION_MEANING setting is wrong')
- # elif scope_selector == 'favorite':
- # favorite_filter = models.Q(thread__favorited_by = request_user)
- # if 'followit' in settings.INSTALLED_APPS:
- # followed_users = request_user.get_followed_users()
- # favorite_filter |= models.Q(author__in = followed_users)
- # favorite_filter |= models.Q(answers__author__in = followed_users)
- # qs = qs.filter(favorite_filter)
- #
- # #user contributed questions & answers
- # if author_selector:
- # try:
- # #todo maybe support selection by multiple authors
- # u = User.objects.get(id=int(author_selector))
- # qs = qs.filter(
- # models.Q(author=u, deleted=False) \
- # | models.Q(answers__author=u, answers__deleted=False)
- # )
- # meta_data['author_name'] = u.username
- # except User.DoesNotExist:
- # meta_data['author_name'] = None
- #
- # #get users tag filters
- # ignored_tag_names = None
- # if request_user and request_user.is_authenticated():
- # uid_str = str(request_user.id)
- # #mark questions tagged with interesting tags
- # #a kind of fancy annotation, would be nice to avoid it
- # interesting_tags = Tag.objects.filter(
- # user_selections__user=request_user,
- # user_selections__reason='good'
- # )
- # ignored_tags = Tag.objects.filter(
- # user_selections__user=request_user,
- # user_selections__reason='bad'
- # )
- #
- # meta_data['interesting_tag_names'] = [tag.name for tag in interesting_tags]
- #
- # ignored_tag_names = [tag.name for tag in ignored_tags]
- # meta_data['ignored_tag_names'] = ignored_tag_names
- #
- # if interesting_tags or request_user.has_interesting_wildcard_tags():
- # #expensive query
- # if request_user.display_tag_filter_strategy == \
- # const.INCLUDE_INTERESTING:
- # #filter by interesting tags only
- # interesting_tag_filter = models.Q(thread__tags__in = interesting_tags)
- # if request_user.has_interesting_wildcard_tags():
- # interesting_wildcards = request_user.interesting_tags.split()
- # extra_interesting_tags = Tag.objects.get_by_wildcards(
- # interesting_wildcards
- # )
- # interesting_tag_filter |= models.Q(thread__tags__in = extra_interesting_tags)
- #
- # qs = qs.filter(interesting_tag_filter)
- # else:
- # pass
- # #simply annotate interesting questions
- ## qs = qs.extra(
- ## select = SortedDict([
- ## (
- ## # TODO: [tags] Update this query so that it fetches tags from Thread
- ## 'interesting_score',
- ## 'SELECT COUNT(1) FROM askbot_markedtag, question_tags '
- ## + 'WHERE askbot_markedtag.user_id = %s '
- ## + 'AND askbot_markedtag.tag_id = question_tags.tag_id '
- ## + 'AND askbot_markedtag.reason = \'good\' '
- ## + 'AND question_tags.question_id = question.id'
- ## ),
- ## ]),
- ## select_params = (uid_str,),
- ## )
- #
- # # get the list of interesting and ignored tags (interesting_tag_names, ignored_tag_names) = (None, None)
- #
- # if ignored_tags or request_user.has_ignored_wildcard_tags():
- # if request_user.display_tag_filter_strategy == const.EXCLUDE_IGNORED:
- # #exclude ignored tags if the user wants to
- # qs = qs.exclude(thread__tags__in=ignored_tags)
- # if request_user.has_ignored_wildcard_tags():
- # ignored_wildcards = request_user.ignored_tags.split()
- # extra_ignored_tags = Tag.objects.get_by_wildcards(
- # ignored_wildcards
- # )
- # qs = qs.exclude(thread__tags__in = extra_ignored_tags)
- # else:
- # pass
- ## #annotate questions tagged with ignored tags
- ## #expensive query
- ## qs = qs.extra(
- ## select = SortedDict([
- ## (
- ## 'ignored_score',
- ## # TODO: [tags] Update this query so that it fetches tags from Thread
- ## 'SELECT COUNT(1) '
- ## + 'FROM askbot_markedtag, question_tags '
- ## + 'WHERE askbot_markedtag.user_id = %s '
- ## + 'AND askbot_markedtag.tag_id = question_tags.tag_id '
- ## + 'AND askbot_markedtag.reason = \'bad\' '
- ## + 'AND question_tags.question_id = question.id'
- ## )
- ## ]),
- ## select_params = (uid_str, )
- ## )
- #
- # if sort_method != 'relevance-desc':
- # #relevance sort is set in the extra statement
- # #only for postgresql
- # orderby = QUESTION_ORDER_BY_MAP[sort_method]
- # qs = qs.order_by(orderby)
- #
- # qs = qs.distinct()
- # qs = qs.select_related(
- # 'thread__last_activity_by__id',
- # 'thread__last_activity_by__username',
- # 'thread__last_activity_by__reputation',
- # 'thread__last_activity_by__gold',
- # 'thread__last_activity_by__silver',
- # 'thread__last_activity_by__bronze',
- # 'thread__last_activity_by__country',
- # 'thread__last_activity_by__show_country',
- # )
- #
- # related_tags = Tag.objects.get_related_to_search(
- # questions = qs,
- # search_state = search_state,
- # ignored_tag_names = ignored_tag_names
- # )
- # if askbot_settings.USE_WILDCARD_TAGS == True \
- # and request_user.is_authenticated() == True:
- # tagnames = request_user.interesting_tags
- # meta_data['interesting_tag_names'].extend(tagnames.split())
- # tagnames = request_user.ignored_tags
- # meta_data['ignored_tag_names'].extend(tagnames.split())
- # return qs, meta_data, related_tags
-
def added_between(self, start, end):
"""questions added between ``start`` and ``end`` timestamps"""
#todo: goes to thread