summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Dakkar/TweetArchive.pm9
-rw-r--r--lib/Dakkar/TweetArchive/Store.pm31
-rw-r--r--tweet-archive.pl3
3 files changed, 42 insertions, 1 deletions
diff --git a/lib/Dakkar/TweetArchive.pm b/lib/Dakkar/TweetArchive.pm
index 9d914fd..3c0d35e 100644
--- a/lib/Dakkar/TweetArchive.pm
+++ b/lib/Dakkar/TweetArchive.pm
@@ -48,5 +48,12 @@ sub home_timeline($self,$since_id) {
});
}
-1;
+sub friends($self) {
+ return $self->client->friends({count=>200});
+}
+sub followers($self) {
+ return $self->client->followers({count=>200});
+}
+
+1;
diff --git a/lib/Dakkar/TweetArchive/Store.pm b/lib/Dakkar/TweetArchive/Store.pm
index e4a4f3b..b716166 100644
--- a/lib/Dakkar/TweetArchive/Store.pm
+++ b/lib/Dakkar/TweetArchive/Store.pm
@@ -72,6 +72,22 @@ SQL
);
}
+sub store_friends($self,$friends) {
+ my $friends_str = $json_printer->encode($friends);
+
+ $self->dbh->do(<<'SQL', {}, $friends_str);
+INSERT INTO friends(users) VALUES(?)
+SQL
+}
+
+sub store_followers($self,$followers) {
+ my $followers_str = $json_printer->encode($followers);
+
+ $self->dbh->do(<<'SQL', {}, $followers_str);
+INSERT INTO followers(users) VALUES(?)
+SQL
+}
+
sub _schema_deploy($self,$dbh,$next_version) {
my $method_name = "_schema_deploy_${next_version}";
if (my $method = $self->can($method_name)) {
@@ -115,4 +131,19 @@ CREATE TABLE tweets (
SQL
}
+sub _schema_deploy_2($self,$dbh) {
+ $dbh->do(<<'SQL');
+CREATE TABLE followers (
+ taken_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP PRIMARY KEY,
+ users JSONB NOT NULL
+)
+SQL
+ $dbh->do(<<'SQL');
+CREATE TABLE friends (
+ taken_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP PRIMARY KEY,
+ users JSONB NOT NULL
+)
+SQL
+}
+
1;
diff --git a/tweet-archive.pl b/tweet-archive.pl
index 170c6af..2424206 100644
--- a/tweet-archive.pl
+++ b/tweet-archive.pl
@@ -26,3 +26,6 @@ my $latest_id = $store->latest_tweet_id;
for my $tweet ($client->home_timeline($latest_id)->@*) {
$store->store_tweet($tweet);
}
+
+$store->store_friends($client->friends);
+$store->store_followers($client->followers);