2019-12-11 15:59:17 +00:00
|
|
|
class Cancerpredictrecord
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include OrbitModel::Status
|
|
|
|
include OrbitModel::Impression
|
|
|
|
# encoding: utf-8
|
|
|
|
include OrbitTag::Taggable
|
|
|
|
include OrbitCategory::Categorizable
|
|
|
|
field :title ,type:String ,default:""
|
|
|
|
field :submit_time ,type:String ,default:""
|
|
|
|
field :result , type:Hash , default:{}
|
2019-12-27 05:49:20 +00:00
|
|
|
field :names , type:Hash , default:{}
|
|
|
|
field :values , type:Hash , default:{}
|
2019-12-11 15:59:17 +00:00
|
|
|
field :submit_numbers , type:Fixnum , default: 1
|
|
|
|
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}
|
|
|
|
scope :is_approved, ->{where(:approved => true)}
|
|
|
|
before_save :set_submit_times
|
|
|
|
def set_submit_times
|
2022-01-26 06:05:57 +00:00
|
|
|
self.submit_time = Cancerpredictrecord.all.count + 1
|
|
|
|
end
|
|
|
|
def check_missing_data
|
|
|
|
missing_keys = self.names.keys - self.result.keys rescue []
|
|
|
|
missing_keys.each{|k| self.result[k] = "" }
|
2019-12-11 15:59:17 +00:00
|
|
|
end
|
|
|
|
end
|