diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2016-12-09 20:49:29 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2016-12-09 20:49:29 +0100 |
commit | 8fad557345adb4d5181e3468df10c81b060ec0f1 (patch) | |
tree | b365fdb25d88cd971057758ccc4f9d0099393272 /watchnews/web.py | |
parent | 0c5e11825fadc575e72746bb1f020630cfd9ef40 (diff) | |
download | watchnews-8fad557345adb4d5181e3468df10c81b060ec0f1.tar.gz watchnews-8fad557345adb4d5181e3468df10c81b060ec0f1.zip |
web: show only feed-items with more than one version
Diffstat (limited to 'watchnews/web.py')
-rw-r--r-- | watchnews/web.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/watchnews/web.py b/watchnews/web.py index c687120..2699554 100644 --- a/watchnews/web.py +++ b/watchnews/web.py @@ -3,6 +3,7 @@ from . import data, css from ll.xist import xsc, parse from ll.xist.ns import html, chars from flask import Flask, url_for +import peewee import re import difflib @@ -66,7 +67,7 @@ class DiffSupport: if line != '': # trailing unchanged text elems += [html.span(line)] - + elems += [ html.br() ] return elems @@ -218,9 +219,15 @@ def get_app(): @app.route('/feed/<id>') def feed(id): feed = data.Feed.get(data.Feed.id == id) - items = data.Item.select() \ - .where(data.Item.feed == feed) \ - .order_by(data.Item.created_date.desc()) + counts = (data.Version.select(data.Version.item.alias('item_id'), + peewee.fn.Count(data.Version.id).alias('count')) + .group_by(data.Version.item) + .alias('counts')) + + items = (data.Item.select() + .join(counts, on=(data.Item.id == counts.c.item_id)) + .where((data.Item.feed == feed) & (counts.c.count > 1)) + .order_by(data.Item.created_date.desc())) return Template.feed(feed, items).string('utf-8') @app.route('/item/<id>') |