First time here? Check out the FAQ!
2

sort questions by number of views

My need is to include a FAQ link in a website that refers Askbot. I consider that the most viewed questions correspond to the most frequently asked ones. For a web site that is talking about continous integration, the link could be as follow: http://askbot.org/en/questions/?sort=views-desc&tags=continuous-integration

Unfortunately, the sorting by number of views is not available and the combinaison of several parameters is not managed.

Samuel's avatar
425
Samuel
asked 2011-09-27 09:44:10 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

2

Sorting by the number of views is possible to add, but if you sort questions by ascending date they will order almost automatically by descending number of views. Also number of views will be affected by ranking in the search engines.

It's a good question how to automatically detect questions for the faq. SO has this http://stackoverflow.com/questions?sort=faq - is it useful?

Evgeny's avatar
13.2k
Evgeny
answered 2011-09-27 19:21:40 -0500
edit flag offensive 0 remove flag delete link

Comments

Yes my need is to detect the faq regarding a given subject (could be a tag or query). For example, it could be useful to include in the chapter "Installing" of the askbot documentation the following link : http://askbot.org/en/question/?sort=faq&tags=installation

Samuel's avatar Samuel (2011-09-28 02:29:58 -0500) edit

Probably, number of votes will be a better approximation of FAQ...

Evgeny's avatar Evgeny (2011-10-07 15:56:46 -0500) edit

not sure. To be able to vote a visitor must be connected and be in a spirit "community". Unfortunately in practise, most of people will only take the answer, that's why I think the faq sorting should also consider the number of views.

Samuel's avatar Samuel (2011-10-11 04:30:38 -0500) edit

I still think that votes are a better predictor of F.A.Q, but the problem may be public reputation system, which motivates people to upvote less often, because of the competition. Maybe we should lower the reputation increase for the questions, or even remove it alltogether. In some other forums I saw a button "I have this question too" - which is kind of the same as a vote, but maybe perceived differently.

Evgeny's avatar Evgeny (2011-10-12 08:32:26 -0500) edit

Me to need sort by view. FAQ will be a different section, where users will get their answers about the site and site's functionalies, features.

Sort by view will help user to get popular questions. Upvote is not always useful. View means what people generally view and votes mean what user generally promote.

Zahid's avatar Zahid (2012-08-03 22:37:12 -0500) edit
add a comment see more comments
1

For those who still want to sort their question by view, I made it, here is my git diff for this feature (maybe I'll do a pull request for it ...)

diff --git a/askbot/const/__init__.py b/askbot/const/__init__.py
index e693a63..48a477a 100644
--- a/askbot/const/__init__.py
+++ b/askbot/const/__init__.py
@@ -50,6 +50,8 @@ POST_SORT_METHODS = (
     ('answers-asc', _('coldest')),
     ('votes-desc', _('most voted')),
     ('votes-asc', _('least voted')),
+    ('views-desc', _('most viewed')),
+    ('views-asc', _('least viewed')),
     ('relevance-desc', _('relevance')),
 )

diff --git a/askbot/models/question.py b/askbot/models/question.py
index 2bb9e80..cf8633f 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -290,7 +290,8 @@ class ThreadManager(models.Manager):
             'answers-asc': 'answer_count',
             'votes-desc': '-score',
             'votes-asc': 'score',
-
+           'views-desc': '-view_count',
+           'views-asc': 'view_count',
             'relevance-desc': '-relevance', # special Postgresql-specific ordering, 'relevance' quaso-column is added by get_for_query()
         }
         orderby = QUESTION_ORDER_BY_MAP[search_state.sort]
diff --git a/askbot/skins/default/templates/main_page/tab_bar.html b/askbot/skins/default/templates/main_page/tab_bar.html
index 17ab810..9620d32 100644
--- a/askbot/skins/default/templates/main_page/tab_bar.html
+++ b/askbot/skins/default/templates/main_page/tab_bar.html
@@ -75,6 +75,15 @@
                 search_state = search_state,
             )
         }}
+        {{macros.reversible_sort_button(
+                button_sort_criterium = 'views',
+                label = gettext('by views'),
+                asc_tooltip = gettext('click to see least viewed questions'),
+                desc_tooltip = gettext('click to see most viewed questions'),
+                current_sort_method = sort,
+                search_state = search_state,
+            )
+        }}
     </div>
 </div>
bgenevaux's avatar
201
bgenevaux
answered 2012-08-09 03:17:24 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments