|
|
@@ -1,4 +1,4 @@
|
|
|
-from pymongo import MongoClient,errors
|
|
|
+from pymongo import MongoClient,errors,DESCENDING,ASCENDING
|
|
|
from bson.objectid import ObjectId
|
|
|
import datetime
|
|
|
import re
|
|
|
@@ -41,8 +41,13 @@ class db():
|
|
|
db_filter["kw"]={"$all": filter["keyword"]}
|
|
|
|
|
|
#print(db_filter)
|
|
|
- q = self.c_articles.find(db_filter,{"html":0,"text":0}).limit(limit).sort("scrap_date")
|
|
|
- count = q.count()
|
|
|
+ res = self.c_articles.find(db_filter,{"html":0,"text":0})
|
|
|
+ if res is not None:
|
|
|
+ q = res.sort("scrap_date",DESCENDING).limit(limit)
|
|
|
+ count = q.count()
|
|
|
+ else:
|
|
|
+ q = []
|
|
|
+ count = 0
|
|
|
return { 'articles': [ self.jsonable(p) for p in q ],
|
|
|
'count' : count }
|
|
|
|