embulk-input-facebook_ads_insights 0.1.2 → 0.1.3

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: 216c608f834dd00d357b5065f346317c1ab0e23b
4
- data.tar.gz: e3c360c8ef84d04c4e4119bba18d7124781f955f
3
+ metadata.gz: d46e96da39a17161b5c84ce1e0f47b984d170311
4
+ data.tar.gz: 5e3558265b4c7201478eb70ab96bcc5ecfc8f467
5
5
  SHA512:
6
- metadata.gz: dcfd7142941bc480c15372b6efa2f297dccbbe6788e762b79598ea6d63bf7d5e3699e6c4c3deeef8ea161fed1b8f54eb4e1cb4ef44ac68fa9589bdff6955028d
7
- data.tar.gz: ccfc9c175adde3185f571fe9404b6e313ceb7bed174a5aa0d7d94721a7c12766c7e6ced0c00fc4ed2652bab413921b33f83441c4b83bf26a9c4572b55a999bc9
6
+ metadata.gz: fe9dca2e749a6f6f94adb57aaf1d788663e10a4c3a31ee9323452c6d2628f846cc212b3f8de96ee0916e7f8c463e8ea91f13f6e2e1d6433df9d21056ae46cee7
7
+ data.tar.gz: 83f87b360a4949455f323e9d949790c0a45077bb37ac70977db477343b9b78fec9ac528d97df328091f0341e23bdd31bccf48c2a595e7840b7e8a4bb2f06dc4c
data/build.gradle CHANGED
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.2"
16
+ version = "0.1.3"
17
17
 
18
18
  sourceCompatibility = 1.8
19
19
  targetCompatibility = 1.8
@@ -16,6 +16,7 @@ import org.embulk.spi.ColumnConfig;
16
16
  import org.slf4j.Logger;
17
17
  import org.slf4j.LoggerFactory;
18
18
 
19
+ import java.util.ArrayList;
19
20
  import java.util.List;
20
21
  import java.util.stream.Collectors;
21
22
 
@@ -31,7 +32,7 @@ public class Client
31
32
  this.pluginTask = pluginTask;
32
33
  }
33
34
 
34
- public APINodeList<AdsInsights> getInsights() throws APIException, InterruptedException
35
+ public List<AdsInsights> getInsights(boolean isPaginationValid) throws APIException, InterruptedException
35
36
  {
36
37
  AdReportRun adReportRun;
37
38
  switch (pluginTask.getObjectType()) {
@@ -56,7 +57,8 @@ public class Client
56
57
  while (adReportRun.fetch().getFieldAsyncPercentCompletion() != 100) {
57
58
  Thread.sleep(ASYNC_SLEEP_TIME);
58
59
  }
59
- return adReportRun.getInsights().execute();
60
+ APINodeList<AdsInsights> adsInsights = adReportRun.getInsights().execute();
61
+ return isPaginationValid ? fetchAllPage(adsInsights) : adsInsights;
60
62
  }
61
63
 
62
64
  // TODO: plz make me dry
@@ -244,6 +246,17 @@ public class Client
244
246
  return request.execute();
245
247
  }
246
248
 
249
+ private List<AdsInsights> fetchAllPage(APINodeList<AdsInsights> adsInsights) throws APIException
250
+ {
251
+ List<AdsInsights> result = new ArrayList<>();
252
+ APINodeList<AdsInsights> next = adsInsights;
253
+ while (!next.isEmpty()) {
254
+ result.addAll(next);
255
+ next = next.nextPage();
256
+ }
257
+ return result;
258
+ }
259
+
247
260
  private APIContext apiContext()
248
261
  {
249
262
  return new APIContext(pluginTask.getAccessToken());
@@ -56,7 +56,7 @@ public class FacebookAdsInsightsInputPlugin
56
56
  try {
57
57
  try (PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
58
58
  Client client = new Client(task);
59
- List<AdsInsights> insights = client.getInsights();
59
+ List<AdsInsights> insights = client.getInsights(!Exec.isPreview());
60
60
  for (AdsInsights insight : insights) {
61
61
  schema.visitColumns(new FacebookAdsInsightsColumnVisitor(insight, pageBuilder, task));
62
62
  pageBuilder.addRecord();
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-facebook_ads_insights
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - naotaka nakane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-10 00:00:00.000000000 Z
11
+ date: 2019-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ files:
50
50
  - README.md
51
51
  - build.gradle
52
52
  - classpath/annotations-13.0.jar
53
- - classpath/embulk-input-facebook_ads_insights-0.1.2.jar
53
+ - classpath/embulk-input-facebook_ads_insights-0.1.3.jar
54
54
  - classpath/facebook-java-business-sdk-4.0.5.jar
55
55
  - classpath/gson-2.5.jar
56
56
  - classpath/guava-20.0.jar