require 'flydata-core/query_job/redshift' require 'flydata-core/table_def/redshift_table_def' module FlydataCore module QueryJob class TableStatus @@domain = 'flydata_redshift_table_status' def self.domain=(domain) @@domain = domain end def self.sdb=(sdb) @@sdb = sdb end def self.where(*args) table_status_items = {} @@sdb.domains[@@domain].items.where(*args).each(select: :all) do |item| class << item # returns the corect (Redshift) table name def table_name FlydataCore::TableDef::RedshiftTableDef.convert_to_valid_table_name(attributes['table_name'].first) end def target_table_names FlydataCore::QueryJob::Redshift.target_table_names(attributes['table_name'].first) end end tn = item.attributes['table_name'].first redshift_table_name = FlydataCore::TableDef::RedshiftTableDef.convert_to_valid_table_name(tn) if redshift_table_name == tn table_status_items[redshift_table_name] ||= item else table_status_items[redshift_table_name] = item end end table_status_items.values end end end end