From 3cea6abe3606ea586b733e943737f77d58f215f9 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 27 Jul 2015 20:51:25 +0200 Subject: reasonable query performace for data_entries --- lib/data_entry.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/data_entry.rb') diff --git a/lib/data_entry.rb b/lib/data_entry.rb index 9f6e786..4eeb66d 100644 --- a/lib/data_entry.rb +++ b/lib/data_entry.rb @@ -1,15 +1,18 @@ module OpenTox class DataEntry - #field :feature_id, type: BSON::ObjectId - #field :compound_id, type: BSON::ObjectId + field :feature_id, type: BSON::ObjectId + field :compound_id, type: BSON::ObjectId # Kludge because csv import removes type information - field :feature_id, type: String - field :compound_id, type: String + #field :feature_id, type: String + #field :compound_id, type: String field :value field :warnings, type: String field :unit, type: String store_in collection: "data_entries" + belongs_to :dataset + has_one :compound + has_one :feature # preferred method for the insertion of data entries # @example DataEntry.find_or_create compound,feature,value @@ -32,5 +35,6 @@ module OpenTox def self.[](compound,feature) self.where(:compound_id => compound.id.to_s, :feature_id => feature.id.to_s).distinct(:value).first end + end end -- cgit v1.2.3