shield_project_ids=ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids=ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
watched_user_blog_ids=Blog.select("id").where("author_id in #{user_ids}").count==0?"":Blog.select("id").where("author_id in #{user_ids}").map{|blog|blog.id}.join(",")
activities=UserActivity.where("(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc')
elsifcontainer_type=="Project"
activities=UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})").order('updated_at desc')
else
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')