Browse Source

HUE-1106 [beeswax] Pagination on /beeswax/query_history page is broken

Romain Rigaux 12 years ago
parent
commit
cace2a22df

+ 5 - 7
apps/beeswax/src/beeswax/templates/list_history.mako

@@ -109,13 +109,11 @@ ${ layout.menubar(section='history') }
                 <td data-sort-value="${time.mktime(query.submission_date.timetuple())}">${query.submission_date.strftime("%x %X")}</td>
                 <td data-sort-value="${time.mktime(query.submission_date.timetuple())}">${query.submission_date.strftime("%x %X")}</td>
                 <td>${show_saved_query(query.design, query)}</td>
                 <td>${show_saved_query(query.design, query)}</td>
                 <td>
                 <td>
-                  <p>
-                    % if len(query.query) > 100:
-                      <code>${collapse_whitespace(query.query[:100])}...</code>
-                    % else:
-                      <code>${collapse_whitespace(query.query)}</code>
-                    % endif
-                  </p>
+                  % if len(query.query) > 100:
+                    <code>${collapse_whitespace(query.query[:100])}...</code>
+                  % else:
+                    <code>${collapse_whitespace(query.query)}</code>
+                  % endif
                 </td>
                 </td>
                 <td>${query.owner}</td>
                 <td>${query.owner}</td>
                 <td>${models.QueryHistory.STATE[query.last_state]}</td>
                 <td>${models.QueryHistory.STATE[query.last_state]}</td>

+ 5 - 1
apps/beeswax/src/beeswax/tests.py

@@ -1317,7 +1317,11 @@ def test_history_page():
 
 
   # Only show Beeswax queries
   # Only show Beeswax queries
   response = do_view('')
   response = do_view('')
-  assert_equal('beeswax', response.context['filter_params']['type'])
+  assert_equal({}, response.context['filter_params'])
+
+  # Test pagination
+  response = do_view('?q-page=100')
+  assert_equal(0, len(response.context['page'].object_list))
 
 
 def test_strip_trailing_semicolon():
 def test_strip_trailing_semicolon():
   # Note that there are two queries (both an execute and an explain) scattered
   # Note that there are two queries (both an execute and an explain) scattered

+ 4 - 3
apps/beeswax/src/beeswax/views.py

@@ -212,7 +212,7 @@ def my_queries(request):
   and those in ``list_designs`` (with a ``q-`` prefix). The only thing it disallows
   and those in ``list_designs`` (with a ``q-`` prefix). The only thing it disallows
   is the ``user`` filter, since this view only shows what belongs to the user.
   is the ``user`` filter, since this view only shows what belongs to the user.
   """
   """
-  DEFAULT_PAGE_SIZE = 40
+  DEFAULT_PAGE_SIZE = 30
   app_name= get_app_name(request)
   app_name= get_app_name(request)
 
 
   # Extract the history list.
   # Extract the history list.
@@ -262,7 +262,8 @@ def list_query_history(request):
                           Default to "-date".
                           Default to "-date".
     auto_query=<bool>   - Show auto generated actions (drop table, read data, etc). Default False
     auto_query=<bool>   - Show auto generated actions (drop table, read data, etc). Default False
   """
   """
-  DEFAULT_PAGE_SIZE = 20
+  DEFAULT_PAGE_SIZE = 30
+  prefix = 'q-'
 
 
   share_queries = conf.SHARE_SAVED_QUERIES.get() or request.user.is_superuser
   share_queries = conf.SHARE_SAVED_QUERIES.get() or request.user.is_superuser
 
 
@@ -273,7 +274,7 @@ def list_query_history(request):
   app_name= get_app_name(request)
   app_name= get_app_name(request)
   querydict_query['type'] = app_name
   querydict_query['type'] = app_name
 
 
-  page, filter_params = _list_query_history(request.user, querydict_query, DEFAULT_PAGE_SIZE)
+  page, filter_params = _list_query_history(request.user, querydict_query, DEFAULT_PAGE_SIZE, prefix)
 
 
   return render('list_history.mako', request, {
   return render('list_history.mako', request, {
     'request': request,
     'request': request,