AutoCommit Mit Jun 17 13:03:07 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-06-17 13:03:07 +02:00
parent efe17c681f
commit 7ce34e9d29
4 changed files with 19 additions and 5 deletions

View File

@@ -22,7 +22,7 @@ group :assets do
gem 'therubyracer', :platforms => :ruby gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3' gem 'uglifier', '>= 1.0.3'
end end
gem 'active_record_query_trace'
gem 'jquery-rails' gem 'jquery-rails'

View File

@@ -21,7 +21,7 @@ class Neuigkeit < ActiveRecord::Base
has_many :nlinks, :dependent=> :destroy has_many :nlinks, :dependent=> :destroy
has_one :meeting has_one :meeting
has_many :attachments, :as=>:parent has_many :attachments, :as=>:parent
has_one :title_pic, :class_name=>"Attachment", :as=>:parent, :conditions=>["attachments.flag_titlepic =?", true]
validates :rubrik, :presence=>true validates :rubrik, :presence=>true
@@ -29,7 +29,7 @@ class Neuigkeit < ActiveRecord::Base
translates :title,:text, :versioning=>{:gem=>:paper_trail, :options=>{:fallbacks_for_empty_translations => true}} translates :title,:text, :versioning=>{:gem=>:paper_trail, :options=>{:fallbacks_for_empty_translations => true}}
mount_uploader :picture, PictureUploader mount_uploader :picture, PictureUploader
default_scope order(:cache_order) default_scope order(:cache_order).includes(:calentries).includes(:title_pic)
scope :recent, -> { published.limit(10)} scope :recent, -> { published.limit(10)}
scope :unpublished, -> {where("datum > ? OR datum IS NULL", Time.now)} scope :unpublished, -> {where("datum > ? OR datum IS NULL", Time.now)}
scope :published_scope, ->{where("datum <= ? AND datum IS NOT NULL", Time.now)} scope :published_scope, ->{where("datum <= ? AND datum IS NOT NULL", Time.now)}
@@ -66,8 +66,9 @@ class Neuigkeit < ActiveRecord::Base
if self.has_meeting? if self.has_meeting?
return self.meeting.meetingtyp.picture return self.meeting.meetingtyp.picture
else else
unless self.attachments.where(flag_titlepic: true).first.nil? unless self.title_pic.nil?
return self.attachments.where(flag_titlepic: true).first.datei # return self.attachments.where(flag_titlepic: true).first.datei
return self.title_pic.datei
else else
return self.picture return self.picture
end end

View File

@@ -0,0 +1 @@
ActiveRecordQueryTrace.enabled=true

View File

@@ -0,0 +1,12 @@
class AddIndexForNeuigkeiten < ActiveRecord::Migration
def up
add_index :neuigkeiten, :rubrik_id
add_index :calentries, [:object_type, :object_id]
add_index :attachments, [:parent_type, :parent_id]
add_index :attachments, [:flag_titlepic, :parent_type, :parent_id]
add_index :neuigkeit_translations, :neuigkeit_id
end
def down
end
end