[DEV] add basic capability ro orderby...
This commit is contained in:
parent
70505394fe
commit
271bff816c
@ -129,9 +129,10 @@ class DataInterface():
|
|||||||
return self.bdd
|
return self.bdd
|
||||||
return self.filter_object_values(self.bdd, filter)
|
return self.filter_object_values(self.bdd, filter)
|
||||||
|
|
||||||
def gets_where(self, select, filter=None):
|
def gets_where(self, select, filter=None, order_by=None):
|
||||||
debug.info("gets " + self.name)
|
debug.info("gets " + self.name)
|
||||||
tmp_list = self.get_sub_list(self.bdd, select)
|
tmp_list = self.get_sub_list(self.bdd, select)
|
||||||
|
tmp_list = self.order_by(tmp_list, order_by)
|
||||||
return self.filter_object_values(tmp_list, filter);
|
return self.filter_object_values(tmp_list, filter);
|
||||||
|
|
||||||
def get(self, _id):
|
def get(self, _id):
|
||||||
@ -275,6 +276,24 @@ class DataInterface():
|
|||||||
out.append(elem)
|
out.append(elem)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
def order_by(self, _values, _order):
|
||||||
|
if _order == None:
|
||||||
|
return _values
|
||||||
|
if len(_order) == 0:
|
||||||
|
return _values
|
||||||
|
value_order = _order[0]
|
||||||
|
out = []
|
||||||
|
out_unclassable = []
|
||||||
|
for elem in _values:
|
||||||
|
if value_order not in elem.keys():
|
||||||
|
out_unclassable.append(elem);
|
||||||
|
continue
|
||||||
|
out.append(elem);
|
||||||
|
out = sorted(out, key=lambda x: x[value_order])
|
||||||
|
for elem in out_unclassable:
|
||||||
|
out.append(elem);
|
||||||
|
return out;
|
||||||
|
|
||||||
def filter_object_values(self, _values, _filter):
|
def filter_object_values(self, _values, _filter):
|
||||||
out = []
|
out = []
|
||||||
if _filter == None:
|
if _filter == None:
|
||||||
|
Loading…
Reference in New Issue
Block a user