修改后端bug

This commit is contained in:
sylor_huang@126.com 2020-05-25 11:19:59 +08:00
parent 73699a0937
commit bc5f695094
2 changed files with 12 additions and 11 deletions

View File

@ -2,8 +2,9 @@ module Projectable
extend ActiveSupport::Concern
included do
has_many :projects, -> { order(position: :asc) }
has_many :projects
scope :order_position, ->{order(position: :asc)}
scope :without_content, -> { select(column_names - ['content'])}
end

View File

@ -1,18 +1,18 @@
class AddIndexForProjectLanguageAndCategory < ActiveRecord::Migration[5.2]
def change
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.each do |i|
puts "#######____update_project_category_id____##############{i.id}"
ProejctCategory.reset_counters(i, :projects)
project_categories = Project.joins(:project_category).group("project_categories.id").size
project_categories.each do |k,v|
puts "#######____update_project_category_id____##############{k}"
ProjectCategory.update_counters(k, projects_count: v)
end
project_languages = ProjectLanguage.includes(:projects)
project_languages.each do |i|
puts "#######____update_project_language_id____##############{i.id}"
ProjectLanguage.reset_counters(i, :projects)
project_languages = Project.joins(:project_language).group("project_languages.id").size
project_languages.each do |k,v|
puts "#######____update_project_language_id____##############{k}"
ProjectLanguage.update_counters(k, projects_count: v)
end
end
end