Skip to content

Commit

Permalink
Fixed marklogic-community#777: incremental load only looked at conten…
Browse files Browse the repository at this point in the history
…t db for timestamps
  • Loading branch information
grtjn committed Jun 1, 2017
1 parent 8b3ac5d commit 45736ec
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions deploy/lib/server_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1699,13 +1699,15 @@ def filter_to_newer_files(files, options)
end

uris = files.map { |f| xcc.build_target_uri(f, options) }
stamps_db = get_db_timestamps(uris)
stamps_db = get_db_timestamps(uris, options[:db])
stamps_local = files.map { |file_uri| File.mtime(file_uri).getgm.iso8601(5) }

files_with_stamps = files.zip(stamps_local, stamps_db)

filtered = files_with_stamps.select do |file_uri, stamp_locally, stamp_in_db|

stamp_in_db = stamp_in_db || ""

newer = (stamp_locally > stamp_in_db || stamp_in_db.strip.empty?)

if (!newer)
Expand All @@ -1718,11 +1720,11 @@ def filter_to_newer_files(files, options)
filtered.map { |f, stamp1, stamp2| f}
end

def get_db_timestamps(uris)
def get_db_timestamps(uris, target_db)
uris_as_string = uris.map{|i| "\"#{i}\""}.join(",")
q = %Q{for $u in (#{uris_as_string}) return "" || adjust-dateTime-to-timezone(xdmp:timestamp-to-wallclock(xdmp:document-timestamp($u)), xs:dayTimeDuration("PT0H"))}

result = execute_query q, :db_name => @properties["ml.content-db"]
result = execute_query q, :db_name => target_db
parse_body(result.body).split("\n")
end

Expand Down

0 comments on commit 45736ec

Please sign in to comment.