修改后端bug
This commit is contained in:
parent
73699a0937
commit
bc5f695094
|
@ -2,8 +2,9 @@ module Projectable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
included do
|
||||||
has_many :projects, -> { order(position: :asc) }
|
has_many :projects
|
||||||
|
|
||||||
|
scope :order_position, ->{order(position: :asc)}
|
||||||
scope :without_content, -> { select(column_names - ['content'])}
|
scope :without_content, -> { select(column_names - ['content'])}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
class AddIndexForProjectLanguageAndCategory < ActiveRecord::Migration[5.2]
|
class AddIndexForProjectLanguageAndCategory < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
add_index :project_categories, :id unless index_exists?(:project_categories, :id)
|
add_index :project_categories, :id unless index_exists?(:project_categories, :id)
|
||||||
add_index :project_laguages, :id unless index_exists?(:project_laguages, :id)
|
add_index :project_languages, :id unless index_exists?(:project_languages, :id)
|
||||||
|
|
||||||
project_categories = ProejctCategory.includes(:projects)
|
project_categories = Project.joins(:project_category).group("project_categories.id").size
|
||||||
project_categories.each do |i|
|
project_categories.each do |k,v|
|
||||||
puts "#######____update_project_category_id____##############{i.id}"
|
puts "#######____update_project_category_id____##############{k}"
|
||||||
ProejctCategory.reset_counters(i, :projects)
|
ProjectCategory.update_counters(k, projects_count: v)
|
||||||
end
|
end
|
||||||
|
|
||||||
project_languages = ProjectLanguage.includes(:projects)
|
project_languages = Project.joins(:project_language).group("project_languages.id").size
|
||||||
project_languages.each do |i|
|
project_languages.each do |k,v|
|
||||||
puts "#######____update_project_language_id____##############{i.id}"
|
puts "#######____update_project_language_id____##############{k}"
|
||||||
ProjectLanguage.reset_counters(i, :projects)
|
ProjectLanguage.update_counters(k, projects_count: v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue