lib/dynamoid/adapter.rb
# Takes an array of results that are partitioned, find the most recently updated one, and return only it. Compares each result by
# their id and updated_at attributes; if the updated_at is the greatest, then it must be the correct result.
#
# @param [Array] returned partitioned results from a query
#
# @since 0.2.0
Takes an array of results that are partitioned, find the most recently updated one, and return only it. Compares each result by
their id and updated_at attributes; if the updated_at is the greatest, then it must be the correct result.
Takes an array of results that are partitioned find the most recently updated one and return only it . Compares each result by their id and updated_at attributes ; if the updated_at is the greatest then it must be the correct result .
def result_for_partition(results)
      {}.tap do |hash|
        Array(results).each do |result|
          next if result.nil?
          id = result[:id].split('.').first
          if !hash[id] || (result[:updated_at] > hash[id][:updated_at])
            result[:id] = id
            hash[id] = result
          end
        end
      end.values
    end
def result_for_partition ( results ) { } . tap do | hash | Array ( results ) . each do | result | next if result . nil? id = result [ :id ] . split ( '.' ) . first if ! hash [ id ] || ( result [ :updated_at ] > hash [ id ] [ :updated_at ] ) result [ :id ] = id hash [ id ] = result end end end . values end
Takes an array of results that are partitioned, find the most recently updated one, and return only it.
Takes an array of results that are partitioned find the most recently updated one and return only it .
results
<not_specific>
<not_specific>
returned partitioned results from a query
returned partitioned results from a query
since
None