lib/enrichment_db/census/datum.rb in enrichment_db-0.1.5 vs lib/enrichment_db/census/datum.rb in enrichment_db-0.1.6
- old
+ new
@@ -2,33 +2,11 @@
class EnrichmentDb::Census::Datum < EnrichmentDb::DatumModel
attr_reader :id
DATABASE_NAME = 'censis'
+ UID_NAME = 'region_id'
- def self.by_id(table_name, id)
- puts "Finding object from #{table_name} with region_id = '#{id}'."
- query = "SELECT * FROM #{DATABASE_NAME}.#{table_name} where region_id = $1"
- values = [id]
-
- result = EnrichmentDb.request(DATABASE_NAME, query, values)
-
- if result.ntuples == 1
- puts "Found object with region_id = '#{id}'"
- format_result(result, id)
- else
- puts "Nothing found"
- nil
- end
- end
-
- def self.format_result(result, id)
- result = result[0]
- result = EnrichmentDb::Helper.hash_float_str_to_float(result)
- region_type = result['region_type']
- region_type = region_type[0..-2]
- region = EnrichmentDb::Geo.const_get(region_type).by_id(id.to_i)
- region = EnrichmentDb::Helper.hash_float_str_to_float(region)
- result['region'] = region
- result
+ def self.format_result(result)
+ EnrichmentDb::Helper.format_geo_result(result)
end
end