From 3d843d85c0fc5c814d063c26b418e6e2864b4025 Mon Sep 17 00:00:00 2001 From: Kang-Kyu Lee Date: Mon, 16 Oct 2017 15:24:45 -0700 Subject: [PATCH 1/2] Try to make test pass without ConnectionError to avoid Funky::ConnectionError: {"error":{"code":1,"message":"Please reduce the amount of data you're asking for, then retry your request"}} used fetch array: true method back, but still used fetch_all for videos with since option --- lib/funky/connections/api.rb | 2 +- lib/funky/page.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/funky/connections/api.rb b/lib/funky/connections/api.rb index 3312600..8e72db7 100644 --- a/lib/funky/connections/api.rb +++ b/lib/funky/connections/api.rb @@ -35,7 +35,7 @@ def self.fetch_multiple_pages(uri) json = json_for(uri) if json[:data].empty? @try_count ||= 0 - if @previous_timestamp && @try_count < 1 && (Date.parse @previous_timestamp rescue nil) + if @previous_timestamp && @try_count < 10 && (Date.parse @previous_timestamp rescue nil) timestamp = (Date.parse(@previous_timestamp) - 1).strftime('%F') @try_count += 1 @previous_timestamp = timestamp diff --git a/lib/funky/page.rb b/lib/funky/page.rb index cff11f4..567e4d2 100644 --- a/lib/funky/page.rb +++ b/lib/funky/page.rb @@ -31,8 +31,13 @@ def self.find(page_id) # fetched by Facebook Graph API. def videos(options = {}) path_query = "#{id}/videos?fields=id,title,description,created_time,length,comments.limit(0).summary(true),likes.limit(0).summary(true),reactions.limit(0).summary(true)" - path_query << "&since=#{options[:since]}" if options[:since] - videos = Funky::Connection::API.fetch_all(path_query) + videos = [] + if options[:since] + path_query << "&since=#{options[:since]}" + videos = Funky::Connection::API.fetch_all(path_query) + else + videos = Funky::Connection::API.fetch(path_query, is_array: true) + end videos.map {|video| Video.new(video) } end From 1ad6d548c6dca82c520e7d59e649e541adacb858 Mon Sep 17 00:00:00 2001 From: Kang-Kyu Lee Date: Mon, 16 Oct 2017 15:42:32 -0700 Subject: [PATCH 2/2] [ci skip] bump the version --- CHANGELOG.md | 5 +++++ lib/funky/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e412060..cb8e64d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ For more information about changelogs, check [Keep a Changelog](http://keepachangelog.com) and [Vandamme](http://tech-angels.github.io/vandamme). +## 0.2.30 - 2017/10/16 + +* [BUGFIX] Test should pass when call Page#videos. Partly revert the change +of version 0.2.28 + ## 0.2.29 - 2017/10/16 * [ENHANCEMENT] Use request to get app access token. Do not use diff --git a/lib/funky/version.rb b/lib/funky/version.rb index 46d98e1..9545580 100644 --- a/lib/funky/version.rb +++ b/lib/funky/version.rb @@ -1,3 +1,3 @@ module Funky - VERSION = "0.2.29" + VERSION = "0.2.30" end