script/lib/iri_tweet/utils.py
changeset 203 8124cde38141
parent 122 4c3a15877f80
child 242 cdd7d3c0549c
child 248 ffb0a6d08000
--- a/script/lib/iri_tweet/utils.py	Tue Jun 28 22:23:56 2011 +0200
+++ b/script/lib/iri_tweet/utils.py	Thu Jun 30 02:10:21 2011 +0200
@@ -326,13 +326,17 @@
                       help="quiet", metavar="QUIET", default=0)
 
     
-def get_filter_query(session, start_date, end_date, hashtags, tweet_exclude_table):
+def get_filter_query(session, start_date, end_date, hashtags, tweet_exclude_table, user_whitelist):
     
     query = session.query(Tweet).join(EntityHashtag).join(Hashtag)
     if tweet_exclude_table is not None:
         query = query.filter(~Tweet.id.in_(select([tweet_exclude_table.c.id]))) #@UndefinedVariable
         
     query = query.filter(Tweet.created_at >=  start_date).filter(Tweet.created_at <=  end_date)
+
+    if user_whitelist:
+        query = query.join(User).filter(User.screen_name.in_(user_whitelist))
+
     
     if hashtags :
         def merge_hash(l,h):
@@ -341,6 +345,7 @@
         htags = reduce(merge_hash, hashtags, [])
         
         query = query.filter(or_(*map(lambda h: Hashtag.text.contains(h), htags))) #@UndefinedVariable
+        
     
     return query