summaryrefslogtreecommitdiff
path: root/lib/Dakkar/TweetArchive/Store.pm
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-07-03 21:15:12 +0000
committerdakkar <dakkar@thenautilus.net>2018-07-03 21:15:12 +0000
commit47a86d3eafaa6f938083b86893027af5d76f8a87 (patch)
tree3de6cbecbb915fd36b55c809687b9142127c667a /lib/Dakkar/TweetArchive/Store.pm
parentoops (diff)
downloadtweet-archive-47a86d3eafaa6f938083b86893027af5d76f8a87.tar.gz
tweet-archive-47a86d3eafaa6f938083b86893027af5d76f8a87.tar.bz2
tweet-archive-47a86d3eafaa6f938083b86893027af5d76f8a87.zip
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`)
Diffstat (limited to 'lib/Dakkar/TweetArchive/Store.pm')
-rw-r--r--lib/Dakkar/TweetArchive/Store.pm19
1 files changed, 19 insertions, 0 deletions
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;