resultSet=Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ",like:"%#{keywords}%").reorder(sort)
resultSet=Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ",like:"%#{keywords}%").reorder(sort)
else
resultSet=Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' ").reorder(sort)
end
@ -250,7 +252,7 @@ class FilesController < ApplicationController
else
resultSet=Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' ").reorder(sort)
@ -1474,15 +1459,15 @@ class UsersController < ApplicationController
#显示更多用户课程
defuser_courses4show
@page=params[:page].to_i+1
@courses=@user.courses.visible.where("is_delete =?",0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10).offset(@page*10)
@courses=@user.favorite_courses.visible.where("is_delete =?",0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10).offset(@page*10)
@projects=@user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10).offset(@page*10)
@all_count=@user.projects.visible.count
@projects=@user.favorite_projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10).offset(@page*10)
@all_count=@user.favorite_projects.visible.count
end
defuser_course_activities
@ -1675,55 +1660,117 @@ class UsersController < ApplicationController
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='HomeworkCommon'
when"course_news"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'News'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='News'
when"course_message"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='Message'
when"course_poll"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='Poll'
when"course_journals"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='JournalsForMessage'
when"project_issue"
@user_activities=UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Project'
act_type='Issue'
when"project_message"
@user_activities=UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='Message'
when"user_journals"
@user_activities=UserActivity.where("container_type = 'Principal' and act_type= 'JournalsForMessage' and container_id = #{@user.id}").order('updated_at desc').limit(10).offset(@page*10)
container_type='Principal'
act_type='JournalsForMessage'
when"current_user"
@user_activities=UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page*10)
sql="user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))"
end
ifUser.current!=@user
sql+=" and user_id = #{@user.id}"
end
else
# @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page * 10)
# when "course_news"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'News'").order('updated_at desc').limit(10).offset(@page * 10)
# when "course_message"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10)
# when "course_poll"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page * 10)
# when "course_journals"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page * 10)
# when "project_issue"
# @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('updated_at desc').limit(10).offset(@page * 10)
# when "project_message"
# @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10)
# when "user_journals"
# @user_activities = UserActivity.where("container_type = 'Principal' and act_type= 'JournalsForMessage' and container_id = #{@user.id}").order('updated_at desc').limit(10).offset(@page * 10)
# when "current_user"
# @user_activities = UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page * 10)
# @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
# "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
# "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " +
# "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10)
# end
# else
# # @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
@projects=@user.favorite_projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)
elsif@course
@courses=@user.favorite_courses.visible.where("is_delete =?",0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10)
count=ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='#{shield_type}' and shield_id=#{container_id}").count
<% projects = @user.projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)%>
<% projects = @user.favorite_projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)%>