|
|
@ -8,9 +8,23 @@ module Trustie
|
|
|
|
after_create :clear_course_events
|
|
|
|
after_create :clear_course_events
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def clear_course_events
|
|
|
|
def clear_course_events
|
|
|
|
Rails.cache.delete("course_events_#{self.act.course_id}".to_sym) if Rails.env.production? && Setting.course_cahce_enabled?
|
|
|
|
if Rails.env.production? && Setting.course_cahce_enabled?
|
|
|
|
|
|
|
|
Rails.cache.delete(cache_key)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cache_key
|
|
|
|
|
|
|
|
course_id = nil
|
|
|
|
|
|
|
|
if Message === self.act
|
|
|
|
|
|
|
|
course_id = self.act.board.course_id
|
|
|
|
|
|
|
|
elsif self.act.respond_to?(:course_id)
|
|
|
|
|
|
|
|
course_id = self.act.course_id
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
"course_events_#{course_id}".to_sym
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|