ソースを参照

[search] Update number of rows and template only after n seconds

Romain Rigaux 11 年 前
コミット
dfc517b

+ 1 - 1
apps/search/src/search/api.py

@@ -181,7 +181,7 @@ class SolrApi(object):
     solr_query = {}      
     solr_query = {}      
     
     
     solr_query['collection'] = collection['name']
     solr_query['collection'] = collection['name']
-    solr_query['rows'] = min(int(collection['template']['rows']), 1000)
+    solr_query['rows'] = min(int(collection['template']['rows'] or 10), 1000)
     solr_query['start'] = min(int(query['start']), 10000)
     solr_query['start'] = min(int(query['start']), 10000)
     
     
     q_template = '(%s)' if len(query['qs']) >= 2 else '%s'
     q_template = '(%s)' if len(query['qs']) >= 2 else '%s'

+ 1 - 1
apps/search/src/search/templates/search2.mako

@@ -523,7 +523,7 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
   
   
   <span data-bind="visible: $root.isEditing()">
   <span data-bind="visible: $root.isEditing()">
     ${ _('by') }
     ${ _('by') }
-    <input type="text" data-bind="value: $root.collection.template.rows, valueUpdate: 'afterkeydown'"></input>
+    <input type="text" data-bind="value: $root.collection.template.rows, valueUpdate:'afterkeydown'"></input>
   </span>
   </span>
   
   
   ${ _(' results') }  
   ${ _(' results') }  

+ 2 - 1
apps/search/static/js/search.ko.js

@@ -347,7 +347,7 @@ var Collection = function (vm, collection) {
   self.template.fieldsSelected.subscribe(function () {
   self.template.fieldsSelected.subscribe(function () {
     vm.search();
     vm.search();
   });
   });
-  self.template.template.extend({ rateLimit: { method: "notifyWhenChangesStop", timeout: 400 } }); // hum?
+  self.template.template.extend({ rateLimit: { method: "notifyWhenChangesStop", timeout: 3000 } });
   self.template.template.subscribe(function () {
   self.template.template.subscribe(function () {
     vm.search();
     vm.search();
   });
   });
@@ -363,6 +363,7 @@ var Collection = function (vm, collection) {
   self.template.rows.subscribe(function(){
   self.template.rows.subscribe(function(){
 	vm.search();
 	vm.search();
   });
   });
+  self.template.rows.extend({ rateLimit: { timeout: 1500, method: "notifyWhenChangesStop" } });
 
 
   self.fields = ko.mapping.fromJS(collection.fields);
   self.fields = ko.mapping.fromJS(collection.fields);
   self.availableFacetFields = ko.computed(function() {
   self.availableFacetFields = ko.computed(function() {