Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

Commit

Permalink
Reduce the size of the data requested to avoid large fixtures.
Browse files Browse the repository at this point in the history
Also sets the default of list_subscribers to 5000.

Close #719
  • Loading branch information
llrs committed Jul 20, 2022
1 parent 8ec6d86 commit d254519
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 42,394 deletions.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# rtweet 1.0.1

- Fixed issue with .Rbuilignore and vignettes

- Reduced fixtures sizes by limiting the page size to the number of requests if
it is smaller than the default page size.

# rtweet 1.0.0

## Breaking changes

Expand Down
2 changes: 1 addition & 1 deletion R/direct_messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ direct_messages <- function(n = 50,
cursor = cursor,
retryonratelimit = retryonratelimit,
verbose = verbose,
page_size = 50,
page_size = if (n >= 50) 50 else n,
get_id = function(x) x$events$id
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/followers.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ get_followers <- function(user, n = 5000,
params[[user_type(user)]] <- user

results <- TWIT_paginate_cursor(token, "/1.1/followers/ids", params,
page_size = 5000,
page_size = if(n >= 5000) 5000 else n,
n = n,
cursor = cursor,
retryonratelimit = retryonratelimit,
Expand Down
2 changes: 1 addition & 1 deletion R/lists_members.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ lists_members <- function(list_id = NULL,
cursor = cursor,
retryonratelimit = retryonratelimit,
verbose = verbose,
page_size = 5000,
page_size = if (n >= 5000) 5000 else n,
get_id = function(x) x$users$id_str
)

Expand Down
2 changes: 1 addition & 1 deletion R/lists_memberships.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lists_memberships <- function(user = NULL,
cursor = cursor,
retryonratelimit = retryonratelimit,
verbose = verbose,
page_size = 1000,
page_size = if (n >= 1000) 1000 else n,
get_id = function(x) x$lists$id_str
)

Expand Down
4 changes: 2 additions & 2 deletions R/lists_subscribers.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
lists_subscribers <- function(list_id = NULL,
slug = NULL,
owner_user = NULL,
n = 20,
n = 5000,
cursor = "-1",
parse = TRUE,
retryonratelimit = NULL,
Expand All @@ -34,7 +34,7 @@ lists_subscribers <- function(list_id = NULL,
cursor = cursor,
retryonratelimit = retryonratelimit,
verbose = verbose,
page_size = 5000,
page_size = if (n >= 5000) 5000 else n,
get_id = function(x) x$users$id_str
)

Expand Down
2 changes: 1 addition & 1 deletion R/lists_subscriptions.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ lists_subscriptions <- function(user,
cursor = cursor,
retryonratelimit = retryonratelimit,
verbose = verbose,
page_size = 1000,
page_size = if (n >= 1000) 1000 else n,
get_id = function(x) x$user_id
)

Expand Down
2 changes: 1 addition & 1 deletion man/lists_subscribers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 17 additions & 21 deletions tests/fixtures/direct_messages.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
http_interactions:
- request:
method: get
uri: https://api.twitter.com/1.1/direct_messages/events/list.json?count=50
uri: https://api.twitter.com/1.1/direct_messages/events/list.json?count=1
body:
encoding: ''
string: ''
Expand All @@ -15,36 +15,32 @@ http_interactions:
reason: OK
message: 'Success: (200) OK'
headers:
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-disposition: attachment; filename=json.json
content-encoding: gzip
content-length: '39'
content-type: application/json;charset=utf-8
date: Wed, 09 Mar 2022 00:05:39 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Wed, 09 Mar 2022 00:05:39 GMT
date: Wed, 20 Jul 2022 16:11:41 GMT
pragma: no-cache
server: tsa_f
set-cookie:
- lang=en; Path=/
- guest_id=v1%3A164678433928566239; Max-Age=34214400; Expires=Sun, 09 Apr 2023
00:05:39 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None
status: 200 OK
strict-transport-security: max-age=631138519
expires: Tue, 31 Mar 1981 05:00:00 GMT
content-type: application/json;charset=utf-8
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
last-modified: Wed, 20 Jul 2022 16:11:41 GMT
x-transaction: 0459d9ed27d0ef62
content-length: '39'
x-access-level: read-write-directmessages
x-connection-hash: aa46e8cfc40bc5e118339b12a8935c140825c6923c956b9d38ba9d63e30b584a
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
content-encoding: gzip
x-xss-protection: '0'
x-rate-limit-limit: '15'
x-rate-limit-reset: '1658334401'
content-disposition: attachment; filename=json.json
x-content-type-options: nosniff
x-rate-limit-remaining: '14'
x-rate-limit-reset: '1646785239'
x-response-time: '114'
x-transaction: 8e30fa7fa2230ba2
x-twitter-response-tags: BouncerCompliant
x-xss-protection: '0'
strict-transport-security: max-age=631138519
x-response-time: '116'
x-connection-hash: ccfb34807bdcd0d758d735abe84ced3ffae3ce919302a587df991c730124e514
body:
encoding: UTF-8
file: no
string: '{"events":[]}'
recorded_at: 2022-03-09 00:05:39 GMT
recorded_at: 2022-07-20 16:11:41 GMT
recorded_with: vcr/1.0.2, webmockr/0.8.0
24 changes: 12 additions & 12 deletions tests/fixtures/lists_memberships.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
http_interactions:
- request:
method: get
uri: https://api.twitter.com/1.1/lists/memberships.json?screen_name=kearneymw&filter_to_owned_lists=TRUE&count=1000&cursor=-1
uri: https://api.twitter.com/1.1/lists/memberships.json?screen_name=kearneymw&filter_to_owned_lists=TRUE&count=200&cursor=-1
body:
encoding: ''
string: ''
Expand All @@ -15,35 +15,35 @@ http_interactions:
reason: OK
message: 'Success: (200) OK'
headers:
date: Sat, 26 Mar 2022 10:48:24 GMT
date: Wed, 20 Jul 2022 16:12:05 GMT
pragma: no-cache
server: tsa_f
status: 200 OK
expires: Tue, 31 Mar 1981 05:00:00 GMT
content-type: application/json;charset=utf-8
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
last-modified: Sat, 26 Mar 2022 10:48:24 GMT
x-transaction: 91d550cf964fa9b6
content-length: '698'
last-modified: Wed, 20 Jul 2022 16:12:05 GMT
x-transaction: e8ca28f2e8d77c8c
content-length: '701'
x-access-level: read-write-directmessages
x-frame-options: SAMEORIGIN
content-encoding: gzip
x-xss-protection: '0'
x-rate-limit-limit: '75'
x-rate-limit-reset: '1648292604'
x-rate-limit-reset: '1658334197'
content-disposition: attachment; filename=json.json
x-content-type-options: nosniff
x-rate-limit-remaining: '74'
x-rate-limit-remaining: '73'
x-twitter-response-tags: BouncerCompliant
strict-transport-security: max-age=631138519
x-response-time: '150'
x-connection-hash: f78ec2a2178dc79626e48785e0852503b1d3ca9f90337a5063bc44ca8d60d211
x-response-time: '154'
x-connection-hash: ccfb34807bdcd0d758d735abe84ced3ffae3ce919302a587df991c730124e514
body:
encoding: UTF-8
file: no
string: '{"next_cursor":0,"next_cursor_str":"0","previous_cursor":0,"previous_cursor_str":"0","lists":[{"id":1365679109435752448,"id_str":"1365679109435752448","name":"test-memberships","uri":"\/rtweet_test\/lists\/test-memberships-66661","subscriber_count":0,"member_count":1,"mode":"public","description":"","slug":"test-memberships-66661","full_name":"@rtweet_test\/test-memberships-66661","created_at":"Sat
Feb 27 15:04:07 +0000 2021","following":true,"user":{"id":1365671359137873920,"id_str":"1365671359137873920","name":"rtweet-test","screen_name":"rtweet_test","location":"","description":"Testing
bot for rtweet","url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":1,"friends_count":1,"listed_count":0,"created_at":"Sat
Feb 27 14:33:58 +0000 2021","favourites_count":10,"utc_offset":null,"time_zone":null,"geo_enabled":false,"verified":false,"statuses_count":923,"lang":null,"contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"F5F8FA","profile_background_image_url":null,"profile_background_image_url_https":null,"profile_background_tile":false,"profile_image_url":"http:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_normal.png","profile_image_url_https":"https:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_normal.png","profile_link_color":"1DA1F2","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":true,"default_profile":true,"default_profile_image":true,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"none","withheld_in_countries":[]}}]}'
recorded_at: 2022-03-26 10:48:25 GMT
bot for rtweet","url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":4,"friends_count":2,"listed_count":0,"created_at":"Sat
Feb 27 14:33:58 +0000 2021","favourites_count":12,"utc_offset":null,"time_zone":null,"geo_enabled":false,"verified":false,"statuses_count":997,"lang":null,"contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"F5F8FA","profile_background_image_url":null,"profile_background_image_url_https":null,"profile_background_tile":false,"profile_image_url":"http:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_normal.png","profile_image_url_https":"https:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_normal.png","profile_link_color":"1DA1F2","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":true,"default_profile":true,"default_profile_image":true,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"none","withheld_in_countries":[]}}]}'
recorded_at: 2022-07-20 16:12:05 GMT
recorded_with: vcr/1.0.2, webmockr/0.8.0
Loading

0 comments on commit d254519

Please sign in to comment.