app/models/trait_bank.rb
# NOTE (IMPORTANT!) - some versions of Virtuoso don't seem to paginate
# correctly, and may skip some entries or produce duplicates. I'm not sure
# why ours is different, but I did check it: pagination seems to work just
# fine (without using an ORDER BY). [shrug] You should probably check!
NOTE (IMPORTANT!) - some versions of Virtuoso don't seem to paginate
correctly, and may skip some entries or produce duplicates. I'm not sure
why ours is different, but I did check it: pagination seems to work just
fine (without using an ORDER BY). [shrug] You should probably check!
NOTE ( IMPORTANT! ) - some versions of Virtuoso don ' t seem to paginate correctly and may skip some entries or produce duplicates . I ' m not sure why ours is different but I did check it : pagination seems to work just fine ( without using an ORDER BY ) . [ shrug ] You should probably check!
def paginate(query, options = {}, &block)
      put_query = false
      results = []
      limit = options[:limit] || default_limit
      limit = limit.to_i
      limit = default_limit if limit == 0
      offset = 0
      begin
        limited_query = query + " LIMIT #{limit}"
        limited_query += " OFFSET #{offset}" if offset > 0
        results = connection.query(limited_query)
        if results && results.count > 0
          unless put_query
            EOL.log("#{query[0..110].gsub(/\s+/m, " ")}...", prefix: "Q")
            put_query = true
          end
          count = offset + results.count
          EOL.log("paginating for more results: #{count}", prefix: ".") if
            count % 10_000
          yield(results)
        end
        offset += limit
      end until results.empty?
    end
def paginate ( query , options = { } , & block ) put_query = false results = [ ] limit = options [ :limit ] || default_limit limit = limit . to_i limit = default_limit if limit == 0 offset = 0 begin limited_query = query + " LIMIT #{limit}" limited_query += " OFFSET #{offset}" if offset > 0 results = connection . query ( limited_query ) if results && results . count > 0 unless put_query EOL . log ( "#{query[0..110].gsub(/\s+/m, " ")}..." , prefix : "Q" ) put_query = true end count = offset + results . count EOL . log ( "paginating for more results: #{count}" , prefix : "." ) if count % 10_000 yield ( results ) end offset += limit end until results . empty? end
NOTE (IMPORTANT!)
NOTE ( IMPORTANT! )
query
<not_specific>
options
<not_specific>
block
<not_specific>