diff --git a/cmd/tests.sh b/cmd/tests.sh index 8218e1a..e06fc4c 100755 --- a/cmd/tests.sh +++ b/cmd/tests.sh @@ -203,6 +203,12 @@ test $(find link_preview_images | wc -l) = $initial_link_preview_images_count # # test $(sqlite3 twitter.db "select is_stub from tweets where id = 1454522147750260742") = 1 +# Test a tweet thread with a deleted account; should generate a user with a fake ID +tw fetch_tweet https://twitter.com/michaelmalice/status/1497272681497980928 +test $(sqlite3 twitter.db "select is_id_fake from users where handle = 'GregCunningham0'") = 1 +test $(sqlite3 twitter.db "select count(*) from tweets where user_id = (select id from users where handle = 'GregCunningham0')") = 1 + + # Test search tw search "from:michaelmalice constitution" test $(sqlite3 twitter.db "select count(*) from tweets where user_id = 44067298 and text like '%constitution%'") -gt "30" # Not sure exactly how many diff --git a/persistence/tweet_trove_queries.go b/persistence/tweet_trove_queries.go index 5d53ace..5f52085 100644 --- a/persistence/tweet_trove_queries.go +++ b/persistence/tweet_trove_queries.go @@ -11,7 +11,7 @@ import ( * Panics if anything goes wrong. */ func (p Profile) SaveTweetTrove(trove TweetTrove) { - for _, u := range trove.Users { + for i, u := range trove.Users { // Download download their tiny profile image err := p.DownloadUserProfileImageTiny(&u) if err != nil { @@ -22,8 +22,14 @@ func (p Profile) SaveTweetTrove(trove TweetTrove) { if err != nil { panic(fmt.Sprintf("Error saving user with ID %d and handle %s: %s", u.ID, u.Handle, err.Error())) } + fmt.Println(u.Handle, u.ID) + // If the User's ID was updated in saving (i.e., Unknown User), update it in the Trove too + trove.Users[i] = u } + // TODO: this is called earlier in the process as well, before parsing. Is that call redundant? Too tired to figure out right now + trove.FillMissingUserIDs() + for _, t := range trove.Tweets { err := p.SaveTweet(t) if err != nil {