update
authorvunhat_minh <vunhat_minh@dwango.co.jp>
Wed, 28 May 2014 05:28:49 +0000 (14:28 +0900)
committervunhat_minh <vunhat_minh@dwango.co.jp>
Wed, 28 May 2014 05:28:49 +0000 (14:28 +0900)
rainbow.db [deleted file]
rainbowstream/db.py
rainbowstream/rainbow.py

diff --git a/rainbow.db b/rainbow.db
deleted file mode 100644 (file)
index f440b2b..0000000
Binary files a/rainbow.db and /dev/null differ
index 0756b3a..e0c7e84 100644 (file)
@@ -14,6 +14,9 @@ class RainbowDB():
         self.engine = create_engine('sqlite:///rainbow.db', echo=False)
 
     def store(self, tweet_id):
+        """
+        Store tweet id
+        """
         Session = sessionmaker(bind=self.engine)
         session = Session()
         m = Map(tweet_id)
@@ -21,13 +24,28 @@ class RainbowDB():
         session.commit()
 
     def rainbow_query(self, rid):
+        """
+        Query base of rainbow id
+        """
         Session = sessionmaker(bind=self.engine)
         session = Session()
         res = session.query(Map).filter("rainbow_id =:rid").params(rid=rid).all()
         return res
 
     def tweet_query(self, tid):
+        """
+        Query base of tweet id
+        """
         Session = sessionmaker(bind=self.engine)
         session = Session()
         res = session.query(Map).filter("tweet_id =:tid").params(tid=tid).all()
         return res
+
+    def truncate(self):
+        """
+        Truncate table
+        """
+        Session = sessionmaker(bind=self.engine)
+        session = Session()
+        session.query(Map).delete()
+        session.commit()
index 8a03f6f..29cba75 100644 (file)
@@ -304,6 +304,7 @@ def quit():
     """
     Exit all
     """
+    db.truncate() 
     os.kill(g['stream_pid'], signal.SIGKILL)
     sys.exit()
 
@@ -351,6 +352,8 @@ def stream():
 
     # The Logo
     ascii_art()
+    g['stuff'] = '1'
+    home()
     # These arguments are optional:
     stream_args = dict(
         timeout=args.timeout,