|
|
|
@ -62,6 +62,8 @@ class Shixun < ApplicationRecord
|
|
|
|
|
scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) }
|
|
|
|
|
scope :find_by_ids,lambda{|k| where(id:k)}
|
|
|
|
|
|
|
|
|
|
after_create :send_tiding
|
|
|
|
|
|
|
|
|
|
# REDO:
|
|
|
|
|
def propaedeutics
|
|
|
|
|
shixun_info.try(:propaedeutics)
|
|
|
|
@ -242,4 +244,11 @@ class Shixun < ApplicationRecord
|
|
|
|
|
def finished_challenges_count(user)
|
|
|
|
|
Game.joins(:myshixun).where(user_id: user.id, status: 2, myshixuns: { shixun_id: id }).count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def send_tiding
|
|
|
|
|
self.tidings << Tiding.new(:user_id => self.user_id, :trigger_user_id => self.user_id, :belong_container_id => self.id, :belong_container_type =>'Shixun', :tiding_type => "System", :viewed => 0)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|