Author: eallen
Date: 2010-10-28 18:09:55 -0400 (Thu, 28 Oct 2010)
New Revision: 4406
Modified:
mgmt/trunk/cumin/python/cumin/grid/job.py
mgmt/trunk/cumin/python/cumin/qmfadapter.py
Log:
Added a max_records attribute to the QmfAdapter to prevent sorts on extra-large data sets
from freezng the UI. The default is 1000
Modified: mgmt/trunk/cumin/python/cumin/grid/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/job.py 2010-10-28 21:04:19 UTC (rev 4405)
+++ mgmt/trunk/cumin/python/cumin/grid/job.py 2010-10-28 22:09:55 UTC (rev 4406)
@@ -108,12 +108,8 @@
submission = values["obj"]
results = self.app.model.get_submission_job_summaries(submission)
- if isinstance(results.data, dict):
- rows = self.process_results(results.data)
- elif isinstance(results.data, list):
- rows = self.process_list_results(results.data)
- else:
- rows = []
+ rows = self.process_list_results(results.data)
+ rows = rows[:self.max_records]
# sort the entore results set
rows = self.sort_rows(rows, options)
@@ -121,17 +117,6 @@
return page, results
- def process_list_results(self, results):
- # the results for this call is a list
- records = list()
-
- if results:
- for rec in results:
- row = self.process_record(None, rec)
- records.append(row)
-
- return records
-
def process_record(self, key, record):
field_data = list()
for column in self.columns:
@@ -164,7 +149,7 @@
def get_count(self, values):
submission = values["obj"]
results = self.app.model.get_submission_job_summaries(submission)
- return results.data and len(results.data) or 0
+ return results.data and min(self.max_records, len(results.data)) or 0
class NonSortableObjectTableColumn(ObjectTableColumn):
def __init__(self, app, name, attr):
Modified: mgmt/trunk/cumin/python/cumin/qmfadapter.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/qmfadapter.py 2010-10-28 21:04:19 UTC (rev 4405)
+++ mgmt/trunk/cumin/python/cumin/qmfadapter.py 2010-10-28 22:09:55 UTC (rev 4406)
@@ -10,8 +10,9 @@
self.app = app
self.method = method
- self.default = dict()
+ self.default = list()
self.columns = list()
+ self.max_records = 1000
def get_count(self, values):
obj = values['obj']
@@ -20,7 +21,7 @@
action = QmfCall(self.app)
results = action.execute(obj, self.method, args)
- return results and len(results) or 0
+ return results and min(len(results), self.max_records) or 0
def get_data(self, values, options):
obj = values['obj']
@@ -32,7 +33,14 @@
if results.error:
results.data = self.default
- rows = self.process_results(results)
+ if isinstance(results.data, dict):
+ rows = self.process_results(results.data)
+ elif isinstance(results.data, list):
+ rows = self.process_list_results(results.data)
+ else:
+ rows = []
+
+ rows = rows[:self.max_records]
rows = self.sort_rows(rows, options)
return rows[options.offset:options.offset + options.limit]
@@ -46,9 +54,24 @@
for key in results:
row = self.process_record(key, results[key])
records.append(row)
+ if len(records) >= self.max_records:
+ break
return records
+ def process_list_results(self, results):
+ # the results for this call is a list
+ records = list()
+
+ if results:
+ for rec in results:
+ row = self.process_record(None, rec)
+ records.append(row)
+ if len(records) >= self.max_records:
+ break
+
+ return records
+
def process_record(self, key, record):
field_data = list()
for column in self.columns:
Show replies by date