|
@@ -31,22 +31,22 @@ class db():
|
|
|
if db_filter["scrap_date"]=={}:
|
|
if db_filter["scrap_date"]=={}:
|
|
|
del db_filter["scrap_date"]
|
|
del db_filter["scrap_date"]
|
|
|
|
|
|
|
|
- if "minweight" in filter and filter != "":
|
|
|
|
|
|
|
+ if "site" in filter and filter["site"] != "":
|
|
|
|
|
+ db_filter["source_name"]={"$regex":".*%s.*"%filter["site"], "$options": 'i'}
|
|
|
|
|
+
|
|
|
|
|
+ if "minweight" in filter and filter["minweight"] != "":
|
|
|
db_filter["weight"]={"$gt":int(filter["minweight"])}
|
|
db_filter["weight"]={"$gt":int(filter["minweight"])}
|
|
|
|
|
|
|
|
if "keyword" in filter and len(filter["keyword"]) >0:
|
|
if "keyword" in filter and len(filter["keyword"]) >0:
|
|
|
db_filter["kw"]={"$all": filter["keyword"]}
|
|
db_filter["kw"]={"$all": filter["keyword"]}
|
|
|
|
|
|
|
|
- #print(db_filter)
|
|
|
|
|
|
|
+ print(db_filter)
|
|
|
q = self.c_articles.find(db_filter,{"html":0,"text":0}).limit(limit)
|
|
q = self.c_articles.find(db_filter,{"html":0,"text":0}).limit(limit)
|
|
|
count = q.count()
|
|
count = q.count()
|
|
|
return { 'articles': [ self.jsonable(p) for p in q ],
|
|
return { 'articles': [ self.jsonable(p) for p in q ],
|
|
|
'count' : count }
|
|
'count' : count }
|
|
|
|
|
|
|
|
- def articles(self, id=None, limit=100):
|
|
|
|
|
- if id is None:
|
|
|
|
|
- return [ self.jsonable(p) for p in self.c_articles.find({"matches":True},{"html":0,"text":0}).limit(limit) ]
|
|
|
|
|
-
|
|
|
|
|
|
|
+ def article(self, id):
|
|
|
ret=self.c_articles.find_one({"_id":ObjectId(id)})
|
|
ret=self.c_articles.find_one({"_id":ObjectId(id)})
|
|
|
return self.jsonable(ret)
|
|
return self.jsonable(ret)
|
|
|
|
|
|