From 47a86d3eafaa6f938083b86893027af5d76f8a87 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 3 Jul 2018 21:15:12 +0000 Subject: get the full text of tweets! https://developer.twitter.com/en/docs/tweets/tweet-updates shows that you can get the full text by passing `tweet_mode=extended` in the request; instead of getting the `extended_tweet`, you'll get the same shape as with normal tweets, but the text will be in `full_text` (not in `text`) --- lib/Dakkar/TweetArchive/Store.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/Dakkar/TweetArchive/Store.pm') diff --git a/lib/Dakkar/TweetArchive/Store.pm b/lib/Dakkar/TweetArchive/Store.pm index b6ce585..9a97ca6 100644 --- a/lib/Dakkar/TweetArchive/Store.pm +++ b/lib/Dakkar/TweetArchive/Store.pm @@ -341,4 +341,23 @@ CREATE TRIGGER tweets_fts_update SQL } +sub _schema_deploy_5($self) { + my $dbh = $self->dbh; + + # get *more* text of a tweet + $dbh->do(<<'SQL'); +CREATE OR REPLACE FUNCTION tweet_text(IN t JSONB) RETURNS text +LANGUAGE sql +IMMUTABLE +RETURNS NULL ON NULL INPUT +PARALLEL SAFE +AS $$ SELECT +CASE t ? 'extended_tweet' + WHEN true THEN COALESCE(t->'extended_tweet'->>'text',t->'extended_tweet'->>'full_text') + ELSE COALESCE(t->>'text',t->>'full_text') +END +$$; +SQL +} + 1; -- cgit v1.2.3