def feed_info_sql(db, c, feed_uid): singleton.mv_on_demand(db, c) c.execute("""select feed_title, feed_desc, feed_filter, feed_html, feed_xml, feed_pubxml, last_modified, interesting, unread, uninteresting, filtered, total, feed_status, feed_private, feed_exempt, feed_dupcheck, feed_errors from v_feeds_snr where feed_uid=? group by feed_uid, feed_title, feed_html, feed_xml """, [feed_uid])
def view_sql(db, c, where, sort, params, overload_threshold): singleton.mv_on_demand(db, c) c.execute("""create temp table articles as select item_uid, item_creator, item_title, item_link, item_content, datetime(item_loaded), date(item_created) as item_created, datetime(item_rated) as item_rated, julianday('now') - julianday(item_created) as delta_created, item_rating, item_rule_uid, item_feed_uid, feed_title, feed_html, feed_xml, snr from fm_items, v_feeds_snr where item_feed_uid=feed_uid and """ + where + """ order by """ + sort + """, item_uid DESC limit ?""", params + [overload_threshold]) c.execute("""create index articles_i on articles(item_uid)""") c.execute("""select tag_item_uid, tag_name, tag_by from fm_tags, articles where tag_item_uid=item_uid""") tag_dict = dict() for item_uid, tag_name, tag_by in c: tag_dict.setdefault(item_uid, []).append(tag_name) c.execute("""select * from articles order by """ + sort + """, item_uid DESC""") return tag_dict