diff options
-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>') |