diff --git a/articles/controller.py b/articles/controller.py index e89d95c..f5109c7 100644 --- a/articles/controller.py +++ b/articles/controller.py @@ -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() diff --git a/bot/bot.py b/bot/bot.py index 1f8fae5..8ba4b67 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -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) diff --git a/sections/model.py b/sections/model.py index 2d289f3..2816236 100644 --- a/sections/model.py +++ b/sections/model.py @@ -30,7 +30,13 @@ class Section(Base): def __init__(self, url=None,fname=None): 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()