funky 0.2.22 → 0.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e12d14881465b91bcee78d6c9797bc8a12bc69a
4
- data.tar.gz: 25170d89ef0c5554c562201ad37dc39141715f23
3
+ metadata.gz: 9ffc5fe5b87b5624e032a5771737aadcffaf905e
4
+ data.tar.gz: 4f5681d153e82541cb7b766cbffc727d0f3f90c4
5
5
  SHA512:
6
- metadata.gz: 154c3a34ba50d72d6959a09153835ef52f5f5ccc22f3a07857709c8cc1e951f0a1b9c73cc63a1e0f929eb1bfce3681c84ddb1b6cdf7ad06ca24b2ee0ff468f90
7
- data.tar.gz: 9c1cdc566145ad1f43824384babf3337bab3a7959e993ad77ed912511bbacf04469fae6f390797cce754cf5e1dee5f20b36a19379d740a09108029331be76dd6
6
+ metadata.gz: 76bbdb60f31e3c8f2d69b8eca1f086867918c56cc3735fa7dcc980177c3aa12d74110f19547adb215a435f4e99075192879a9fd83c7774e83eddac7cd95f0c99
7
+ data.tar.gz: ce1b4bcbab475fc6364bfd6d9bb3998ccf3e36653f1faacf41c2bd9b930ef94c546db3cf0d9b2e6d56499cd23f74218558e3254f95648accbd4b436982e8d417
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.2.23 - 2017/05/09
10
+
11
+ * [FEATURE] Print out logs for each pagination
12
+ * [BUGFIX] Use cursor-based pagination for `Funky::Page#posts` to resolve
13
+ infinite loop issue when the page has life events with old backdated time.
14
+
9
15
  ## 0.2.22 - 2017/05/05
10
16
 
11
17
  * [FEATURE] Add `Funky::Page#posts`.
@@ -7,6 +7,22 @@ module Funky
7
7
  # @api private
8
8
  module Connection
9
9
  class API < Base
10
+ def self.fetch_all(path_query)
11
+ uri = URI "https://#{host}/v2.9/#{path_query}&limit=100&access_token=#{app_id}%7C#{app_secret}"
12
+ fetch_data_with_paging_token(uri)
13
+ end
14
+
15
+ def self.fetch_data_with_paging_token(uri)
16
+ json = json_for(uri)
17
+ if !json[:data].empty? && json[:paging][:next]
18
+ next_paging_uri = URI json[:paging][:next]
19
+ puts "Fetching '#{uri.path}' with #{ URI.decode_www_form(next_paging_uri.query).to_h['after'] }"
20
+ json[:data] + fetch_data_with_paging_token(next_paging_uri)
21
+ else
22
+ json[:data]
23
+ end
24
+ end
25
+
10
26
  def self.fetch(path_query, is_array: false)
11
27
  uri = URI "https://#{host}/v2.8/#{path_query}&limit=100&access_token=#{app_id}%7C#{app_secret}"
12
28
  is_array ? fetch_multiple_pages(uri).uniq : json_for(uri)
@@ -14,6 +30,7 @@ module Funky
14
30
 
15
31
  def self.fetch_multiple_pages(uri)
16
32
  json = json_for(uri)
33
+ puts "Fetching '#{uri.path}' until #{ URI.decode_www_form(uri.query).to_h['until'] || 'now'}"
17
34
  if json[:data].empty?
18
35
  @try_count ||= 0
19
36
  if @previous_timestamp && @try_count < 1 && (Date.parse @previous_timestamp rescue nil)
data/lib/funky/page.rb CHANGED
@@ -43,7 +43,7 @@ module Funky
43
43
  # @return [Array<Funky::Post>] multiple Funky::Post objects containing data
44
44
  # fetched by Facebook Graph API.
45
45
  def posts
46
- posts = Funky::Connection::API.fetch("#{id}/posts?fields=type,created_time", is_array: true)
46
+ posts = Funky::Connection::API.fetch_all("#{id}/posts?fields=type,created_time")
47
47
  posts.map {|post| Post.new(post)}
48
48
  end
49
49
 
data/lib/funky/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Funky
2
- VERSION = "0.2.22"
2
+ VERSION = "0.2.23"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.22
4
+ version: 0.2.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-06 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler