from main import get_db


db = get_db()
db.tweets.delete_many({"num_keywords": 0})

@@ -1,8 +1,50 @@
+from datetime import datetime, timedelta%0A%0A
 from mai
@@ -61,18 +61,22 @@
 et_db%0A%0A%0A
-db
+tweets
  = get_d
@@ -82,12 +82,413 @@
 db()
-%0Adb.
+.tweets%0A%0A# tweet timestamps are in UTC time%0Atwo_weeks_ago = datetime.utcnow() - timedelta(days=14)%0A%0A# parse tweet timestamps%0Atw = tweets.find(%7B%22datetime%22: %7B%22$exists%22: False%7D%7D)%0Atime_format = %22%25a %25b %25d %25H:%25M:%25S +0000 %25Y%22  # 'Tue Jun 28 15:01:54 +0000 2016'%0Afor t in tw:%0A    dt = datetime.strptime(t%5B%22tweet%22%5D%5B%22created_at%22%5D, time_format)%0A    tweets.update_one(%7B%22_id%22: t%5B%22_id%22%5D%7D, %7B%22$set%22: %7B%22datetime%22: dt%7D%7D)%0A%0A%0A
 twee
@@ -503,16 +503,21 @@
 e_many(%7B
+%0A    
 %22num_key
@@ -525,11 +525,52 @@
 ords%22: 0
+,%0A    %22datetime%22: %7B%22$lt%22: two_weeks_ago%7D%0A
 %7D)%0A

delete tweets older than 2 weeks and with 0 keywords