this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improved --since= for searc, refs #39

Also fixed bug from the sqlite-utils 2.x upgrade caused
by checking db[table].exists instead of db[table].exists()

+7 -16
+7 -16
twitter_to_sqlite/cli.py
··· 787 787 json.dumps(search_args, sort_keys=True, separators=(",", ":")).encode("utf8") 788 788 ).hexdigest() 789 789 790 - if since and db["search_runs_tweets"].exists: 791 - # Find the maximum tweet ID from previous runs of this search 792 - try: 793 - since_id = db.conn.execute( 794 - """ 795 - select max(tweet) from search_runs_tweets where search_run in ( 796 - select id from search_runs where hash = ? 797 - ) 798 - """, 799 - [args_hash], 800 - ).fetchall()[0][0] 801 - except IndexError: 802 - pass 803 - 804 790 tweets = utils.fetch_timeline( 805 791 session, 806 792 "https://api.twitter.com/1.1/search/tweets.json", ··· 810 796 key="statuses", 811 797 stop_after=stop_after, 812 798 since_id=since_id, 799 + since_type="search", 800 + since_key=args_hash, 813 801 ) 814 802 chunk = [] 815 803 first = True 816 804 817 - if not db["search_runs"].exists: 805 + if not db["search_runs"].exists(): 818 806 db["search_runs"].create( 819 807 {"id": int, "name": str, "args": str, "started": str, "hash": str}, pk="id" 820 808 ) ··· 825 813 db["search_runs_tweets"].insert_all( 826 814 [{"search_run": search_run_id, "tweet": tweet["id"]} for tweet in chunk], 827 815 pk=("search_run", "tweet"), 828 - foreign_keys=("search_run", "tweet"), 816 + foreign_keys=( 817 + ("search_run", "search_runs", "id"), 818 + ("tweet", "tweets", "id"), 819 + ), 829 820 replace=True, 830 821 ) 831 822