lib/embulk/input/zendesk/plugin.rb in embulk-input-zendesk-0.1.3 vs lib/embulk/input/zendesk/plugin.rb in embulk-input-zendesk-0.1.4
- old
+ new
@@ -94,18 +94,19 @@
end
def run
method = task[:target]
args = [preview?]
- if !preview? && @start_time
+ if @start_time
args << @start_time.to_i
end
last_data = client.public_send(method, *args) do |record|
record = fetch_related_object(record)
values = extract_values(record)
page_builder.add(values)
+ break if preview? # NOTE: preview take care only 1 record. subresources fetching is slow.
end
page_builder.finish
task_report = {}
if task[:incremental] && last_data && last_data["end_time"]
@@ -121,15 +122,10 @@
private
def fetch_related_object(record)
(task[:includes] || []).each do |ent|
- if preview?
- # Fetching subresource consume ~2 sec for each record. it is too long to preview. so the dummy value used.
- record[ent] = [{dummy: "(#{ent}) dummy value for preview"}]
- else
- record[ent] = client.fetch_subresource(record["id"], task[:target], ent)
- end
+ record[ent] = client.fetch_subresource(record["id"], task[:target], ent)
end
record
end
def client