src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java in embulk-input-zendesk-0.3.1 vs src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java in embulk-input-zendesk-0.3.2
- old
+ new
@@ -211,21 +211,18 @@
private ConfigDiff buildConfigDiff(final PluginTask task, final List<TaskReport> taskReports)
{
final ConfigDiff configDiff = Exec.newConfigDiff();
- if (!taskReports.isEmpty()) {
- if (ZendeskUtils.isSupportAPIIncremental(task.getTarget())) {
- final TaskReport taskReport = taskReports.get(0);
- if (taskReport.has(ZendeskConstants.Field.START_TIME)) {
- final OffsetDateTime offsetDateTime = OffsetDateTime.ofInstant(Instant.ofEpochSecond(
- taskReport.get(JsonNode.class, ZendeskConstants.Field.START_TIME).asLong()),
- ZoneOffset.UTC);
+ if (!taskReports.isEmpty() && task.getIncremental()) {
+ final TaskReport taskReport = taskReports.get(0);
+ if (taskReport.has(ZendeskConstants.Field.START_TIME)) {
+ final OffsetDateTime offsetDateTime = OffsetDateTime.ofInstant(Instant.ofEpochSecond(
+ taskReport.get(JsonNode.class, ZendeskConstants.Field.START_TIME).asLong()), ZoneOffset.UTC);
- configDiff.set(ZendeskConstants.Field.START_TIME,
+ configDiff.set(ZendeskConstants.Field.START_TIME,
offsetDateTime.format(DateTimeFormatter.ofPattern(ZendeskConstants.Misc.RUBY_TIMESTAMP_FORMAT_INPUT)));
- }
}
}
return configDiff;
}
@@ -294,19 +291,22 @@
if (Exec.isPreview()) {
return;
}
}
logger.info("Fetched '{}' records from start_time '{}'", recordCount, startTime);
- if (result.has(ZendeskConstants.Field.END_TIME) && !result.get(ZendeskConstants.Field.END_TIME).isNull()
- && result.has(task.getTarget().getJsonName())) {
- // NOTE: start_time compared as "=>", not ">".
- // If we will use end_time for next start_time, we got the same record that is last fetched
- // end_time + 1 is workaround for that
- taskReport.set("start_time", result.get(ZendeskConstants.Field.END_TIME).asLong() + 1);
- }
- else {
- // Sometimes no record and no end_time fetched on the job, but we should generate start_time on config_diff.
- taskReport.set("start_time", Instant.now().getEpochSecond());
+
+ if (task.getIncremental()) {
+ if (result.has(ZendeskConstants.Field.END_TIME) && !result.get(ZendeskConstants.Field.END_TIME).isNull()
+ && result.has(task.getTarget().getJsonName())) {
+ // NOTE: start_time compared as "=>", not ">".
+ // If we will use end_time for next start_time, we got the same record that is last fetched
+ // end_time + 1 is workaround for that
+ taskReport.set(ZendeskConstants.Field.START_TIME, result.get(ZendeskConstants.Field.END_TIME).asLong() + 1);
+ }
+ else {
+ // Sometimes no record and no end_time fetched on the job, but we should generate start_time on config_diff.
+ taskReport.set(ZendeskConstants.Field.START_TIME, Instant.now().getEpochSecond());
+ }
}
if (numberOfRecords < ZendeskConstants.Misc.MAXIMUM_RECORDS_INCREMENTAL) {
break;
}