|
Check-in Number:
|
464 | |
| Date: |
2010-Mar-07 12:33:14 (local)
2010-Mar-07 20:33:14 (UTC) |
| User: | majid |
| Branch: | |
| Comment: |
create a thread to queue ratings (from thumbs-up/thumbs-down) so they are not
lost if the aggregator is updating feeds and the browser connection is closed. |
| Tickets: |
|
| Inspections: |
|
| Files: |
|
temboz/filters.py 1.6 -> 1.7
--- /tmp/T0uLa4A3 Mon Sep 6 18:17:42 2010
+++ /tmp/T1vLa4A3 Mon Sep 6 18:17:42 2010
@@ -87,13 +87,16 @@
class TagRule(Rule):
def __init__(self, uid, expires, rule):
Rule.__init__(self, uid, expires)
- self.rule = rule
+ self.rule = normalize.lower(rule)
def __str__(self):
return '<TagRule %s %s>' % (self.uid, self.rule)
def test(self, item, feed, feed_uid):
if self.check_expires():
return False
- return self.rule in item['item_tags']
+ for tag in item['item_tags']:
+ if self.rule == normalize.lower(tag):
+ return True
+ return False
def highlight_content(self, html):
return '%s<br><p>Filtered for tag <span class="item tag highlighted">%s</span></p>' \
% (html, self.rule)
temboz/temboz 1.11 -> 1.12
--- /tmp/T03OaGB3 Mon Sep 6 18:17:42 2010
+++ /tmp/T14OaGB3 Mon Sep 6 18:17:42 2010
@@ -74,6 +74,8 @@
pass
updater = update.PeriodicUpdater()
updater.start()
+ rater = update.RatingsWorker(update.ratings_q)
+ rater.start()
server.run()
elif opt == '--kill':
import os
temboz/update.py 1.76 -> 1.77
--- /tmp/T0hPaqC3 Mon Sep 6 18:17:42 2010
+++ /tmp/T1iPaqC3 Mon Sep 6 18:17:42 2010
@@ -273,15 +273,29 @@
finally:
c.close()
-def set_rating(item_uid, rating):
- from singleton import db
- c = db.cursor()
- c.execute("""update fm_items
- set item_rating=?, item_rated=julianday('now')
- where item_uid=?""", [rating, item_uid])
- db.commit()
- c.close()
+ratings_q = Queue.Queue()
+def set_rating(*args):
+ ratings_q.put(args)
+class RatingsWorker(threading.Thread):
+ def __init__(self, in_q):
+ threading.Thread.__init__(self)
+ self.in_q = in_q
+ # we need to do this so temboz --refresh honors Ctrl-C
+ self.setDaemon(True)
+ def run(self):
+ from singleton import db
+ c = db.cursor()
+ while True:
+ item_uid, rating = self.in_q.get()
+ try:
+ c.execute("""update fm_items
+ set item_rating=?, item_rated=julianday('now')
+ where item_uid=?""", [rating, item_uid])
+ db.commit()
+ except:
+ util.print_stack()
+
def catch_up(feed_uid):
feed_uid = int(feed_uid)
from singleton import db