dev_hs
cxt 6 years ago
parent de30ae0cd9
commit 7d49c25d4b

@ -240,7 +240,7 @@ class ApplicationController < ActionController::Base
uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous")) uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous"))
if !User.current.logged? && Rails.env.development? if !User.current.logged? && Rails.env.development?
User.current = User.find 12 User.current = User.find 1
end end

@ -992,13 +992,15 @@ class HomeworkCommonsController < ApplicationController
@total_count = @subjects.size @total_count = @subjects.size
if reorder != "myshixun_count" if reorder != "myshixun_count"
@subjects = @subjects.page(page).per(limit).includes(:shixuns, user: [user_extension: :school]) # @subjects = @subjects.page(page).per(limit).includes(:shixuns, user: [user_extension: :school])
@subjects = @subjects.page(page).per(limit).includes(:shixuns)
else else
@subjects = @subjects[offset, limit] @subjects = @subjects[offset, limit]
unless @subjects.blank? unless @subjects.blank?
subject_ids = @subjects.pluck(:id) subject_ids = @subjects.pluck(:id)
order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1 order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1
@subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, user: [user_extension: :school]) # @subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, user: [user_extension: :school])
@subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns)
end end
end end
end end

@ -87,14 +87,6 @@ class SubjectsController < ApplicationController
@courses = @subject.courses if @subject.excellent @courses = @subject.courses if @subject.excellent
@members = @subject.subject_members.includes(:user) @members = @subject.subject_members.includes(:user)
shixuns = @subject.shixuns.published.pluck(:id)
challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id)
# 实训路径中的所有实训标签
@tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq
# 用户获取的实训标签
# @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq
@user_tags = user_shixun_tags challenge_ids, @user.id
@my_subject_progress = @subject.my_subject_progress
# 访问数变更 # 访问数变更
@subject.increment!(:visits) @subject.increment!(:visits)
end end

@ -6,12 +6,12 @@ end
json.subject_list @subjects do |subject| json.subject_list @subjects do |subject|
json.subject_id subject.id json.subject_id subject.id
json.subject_name subject.name json.subject_name subject.name
json.challenge_tags subject.shixun_tags # json.challenge_tags subject.shixun_tags
json.shixun_count subject.shixuns.unhidden.size json.shixun_count subject.shixuns.unhidden.size
json.myshixun_count subject.shixuns.pluck(:myshixuns_count).sum json.myshixun_count subject.shixuns.pluck(:myshixuns_count).sum
json.creator subject.user&.full_name # json.creator subject.user&.full_name
json.creator_login subject.user&.login # json.creator_login subject.user&.login
json.school subject.user&.school_name # json.school subject.user&.school_name
end end
json.subjects_count @total_count json.subjects_count @total_count

@ -24,25 +24,3 @@ if @subject.excellent
json.course_status subject_course_status course json.course_status subject_course_status course
end end
end end
json.members @members do |member|
json.partial! 'subject_member', locals: { user: member.user }
json.role member.role
end
# 技能标签
json.tags @tags do |tag|
unless tag.blank?
json.tag_name tag
json.status @user_tags.include?(tag)
end
end
# 我的进展
json.progress do
json.my_score @subject.my_subject_score
json.all_score @subject.all_score
json.learned @subject.my_subject_progress
json.time @subject.my_consume_time
end
Loading…
Cancel
Save