summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/models.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/db/models.py b/db/models.py
index 5fa9ffc..e4b5317 100644
--- a/db/models.py
+++ b/db/models.py
@@ -35,7 +35,7 @@ class Problem(collections.namedtuple('Problem', ['id', 'language_id', 'problem_g
@staticmethod
def list():
- return _general_list(Problem, Problem.__sql_prefix)
+ return _general_list(Problem, Problem.__sql_prefix, order='language_id, problem_group_id, id')
@staticmethod
def filter(**kwargs):
@@ -90,7 +90,7 @@ def _general_get(kwargs_dict, clazz, sql_select, row_conversion_fn=_no_row_conve
conn.commit()
return_connection(conn)
-def _general_filter(kwargs_dict, clazz, sql_select, row_conversion_fn=_no_row_conversion):
+def _general_filter(kwargs_dict, clazz, sql_select, row_conversion_fn=_no_row_conversion, order='id'):
conditions = []
parameters = []
for field_name, field_value in kwargs_dict.items():
@@ -103,7 +103,7 @@ def _general_filter(kwargs_dict, clazz, sql_select, row_conversion_fn=_no_row_co
cur = conn.cursor('crsr2') # a named cursor: scrolling is done on the server
cur.arraysize = 10000 # scroll unit in the number of rows
try:
- cur.execute(sql_select + ' where ' + ' and '.join(conditions) + ' order by id', parameters)
+ cur.execute(sql_select + ' where ' + ' and '.join(conditions) + ' order by ' + order, parameters)
result = []
row = cur.fetchone()
while row:
@@ -116,13 +116,13 @@ def _general_filter(kwargs_dict, clazz, sql_select, row_conversion_fn=_no_row_co
conn.commit()
return_connection(conn)
-def _general_list(clazz, sql_select, row_conversion_fn=_no_row_conversion):
+def _general_list(clazz, sql_select, row_conversion_fn=_no_row_conversion, order='id'):
conn = get_connection()
try:
cur = conn.cursor('crsr3') # a named cursor: scrolling is done on the server
cur.arraysize = 10000 # scroll unit in the number of rows
try:
- cur.execute(sql_select + ' order by id')
+ cur.execute(sql_select + ' order by ' + order)
result = []
row = cur.fetchone()
while row: