app/models/resource.rb
# This takes an obnoxiously long time. Not much to be done about that. :\ This
# method helps keep the table a managable size, though.
This takes an obnoxiously long time. Not much to be done about that. :\ This
method helps keep the table a managable size, though.
This takes an obnoxiously long time . Not much to be done about that . : \ This method helps keep the table a managable size though .
def remove_missing_data_point_uris
    EOL.log_call
    low = DataPointUri.minimum(:id)
    max = DataPointUri.maximum(:id)
    batch = 250_000 
    points = []
    while low < max
      points += data_point_uris.
        where(["id > ? AND id < ?", low, low + batch]).
        pluck(:uri)
      low += batch
    end
    points.in_groups_of(1000, false) do |group|
      uris = Set.new(group)
      exist = TraitBank.group_exists?(uris.to_a)
      DataPointUri.where(uri: (uris - exist).to_a).delete_all unless exist.empty?
    end
  end
def remove_missing_data_point_uris EOL . log_call low = DataPointUri . minimum ( :id ) max = DataPointUri . maximum ( :id ) batch = 250_000 points = [ ] while low < max points += data_point_uris . where ( [ "id > ? AND id < ?" , low , low + batch ] ) . pluck ( :uri ) low += batch end points . in_groups_of ( 1000 , false ) do | group | uris = Set . new ( group ) exist = TraitBank . group_exists? ( uris . to_a ) DataPointUri . where ( uri : ( uris - exist ) . to_a ) . delete_all unless exist . empty? end end
This takes an obnoxiously long time.
This takes an obnoxiously long time .
# data_point_uris is NOT indexed (doesn't really need to be except here), so # doing a lot of work to make the query finish. This still takes a long # time. :| # Huge batches, but I checked that this was okay.