|
@@ -1,5 +1,6 @@
|
|
import asyncio
|
|
import asyncio
|
|
from random import randint
|
|
from random import randint
|
|
|
|
+from operator import itemgetter
|
|
|
|
|
|
@asyncio.coroutine
|
|
@asyncio.coroutine
|
|
def get_random_record(container):
|
|
def get_random_record(container):
|
|
@@ -52,4 +53,8 @@ def get_fortunes(container):
|
|
yield from cur.execute('SELECT * FROM fortune')
|
|
yield from cur.execute('SELECT * FROM fortune')
|
|
fortunes = yield from cur.fetchall()
|
|
fortunes = yield from cur.fetchall()
|
|
|
|
|
|
|
|
+ fortunes.append({'id': 0, 'message': 'Additional fortune added at request time.'})
|
|
|
|
+
|
|
|
|
+ fortunes.sort(key=itemgetter('message'))
|
|
|
|
+
|
|
return fortunes
|
|
return fortunes
|