Created
October 6, 2019 17:15
-
-
Save simonw/656a8c6e4688f720773c474080abe1b0 to your computer and use it in GitHub Desktop.
Query a twitter-to-sqlite database and find the "deepest" tweets in a reply thread, adapted from https://gist.github.com/robinhouston/f689a4b833dc027a3fd97e3de855927b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with recursive thread as ( | |
select id, in_reply_to_status_id, 0 as depth | |
from tweets | |
where in_reply_to_status_id is null | |
union | |
select tweets.id, tweets.in_reply_to_status_id, 1 + thread.depth as depth | |
from thread join tweets on tweets.in_reply_to_status_id = thread.id) | |
select * from thread order by depth desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similar solution from Piers Cawley: https://twitter.com/pdcawley/status/1180898024832327680