article update
This commit is contained in:
@@ -10,4 +10,4 @@ def get_all():
|
||||
return Article.query.order_by(Article.published_date.desc()).all()
|
||||
|
||||
def search(s):
|
||||
return Article.query.filter(Article.title.like("%"+s+"%")).order_by(Article.published_date.desc()).all()
|
||||
return Article.query.filter(Article.title.like("%"+s+"%")).order_by(Article.published_date.desc()).limit(20).all()
|
||||
|
||||
@@ -98,8 +98,7 @@ def handle(handler,msg):
|
||||
lg.debug(msg['data'])
|
||||
|
||||
def make_article_json(art):
|
||||
|
||||
res={"type":"article", "title":art.title, "id": str(art.id), "url": art.url, "message_text": art.title + " " + art.url}
|
||||
res={"type":"article", "title":art.title+" (" +str(art.section.title())+")", "id": str(art.id), "url": art.url, "message_text": art.title + " " + art.url}
|
||||
if art.image != None:
|
||||
lg.debug("http://crawler.fachschaften.at/"+str(art.image))
|
||||
res["thumb_url"]="http://crawler.fachschaften.at/"+str(art.image)
|
||||
|
||||
@@ -31,6 +31,12 @@ class Section(Base):
|
||||
self.url=url
|
||||
self.foreign_name=fname
|
||||
|
||||
def title(self):
|
||||
t=self.name
|
||||
if t == None or t.strip()=="":
|
||||
t=self.foreign_name
|
||||
return t
|
||||
|
||||
@classmethod
|
||||
def find_or_create(cls, fname):
|
||||
s=Section.query.filter(Section.foreign_name==fname).first()
|
||||
|
||||
Reference in New Issue
Block a user