amend course search
This commit is contained in:
parent
e9bd8a8f3e
commit
0f51480bab
|
@ -138,6 +138,17 @@ class ProjectsController < ApplicationController
|
|||
@project_count = @projects_all.count
|
||||
@project_pages = Paginator.new @project_count, per_page_option, params['page']
|
||||
|
||||
#gcm activity count
|
||||
|
||||
@project_activity_count=Hash.new
|
||||
|
||||
@projects_all.each do |project|
|
||||
@project_activity_count[project.id]=0
|
||||
end
|
||||
|
||||
@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
||||
|
||||
#gcm end
|
||||
|
||||
case params[:project_sort_type]
|
||||
when '0'
|
||||
|
@ -149,6 +160,14 @@ class ProjectsController < ApplicationController
|
|||
when '2'
|
||||
@projects = @projects_all.order("watchers_count desc")
|
||||
@s_type = 2
|
||||
|
||||
#gcm
|
||||
when '3'
|
||||
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
|
||||
@projects=handle_project @projects_all,@project_activity_count
|
||||
@s_type = 3
|
||||
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||
|
||||
else
|
||||
@projects = @projects = @projects_all.order("grade desc")
|
||||
@s_type = 1
|
||||
|
@ -193,22 +212,16 @@ class ProjectsController < ApplicationController
|
|||
@project_count = @projects_all.count
|
||||
@project_pages = Paginator.new @project_count, per_page_option, params['page']
|
||||
|
||||
#gcm activity count
|
||||
#gcm activity count
|
||||
|
||||
@project_activity_count=Hash.new
|
||||
|
||||
#count initialize
|
||||
@projects_all.each do |project|
|
||||
@project_activity_count[project.id]=0
|
||||
end
|
||||
|
||||
@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
||||
|
||||
|
||||
#movebegin
|
||||
|
||||
#moveend
|
||||
|
||||
#gcm end
|
||||
#@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
||||
#gcm end
|
||||
|
||||
|
||||
case params[:project_sort_type]
|
||||
|
@ -216,27 +229,48 @@ class ProjectsController < ApplicationController
|
|||
@projects = @projects_all.order("created_on desc")
|
||||
@s_type = 0
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
when '1'
|
||||
@projects = @projects_all.order("course_ac_para desc")
|
||||
@s_type = 1
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
when '2'
|
||||
@projects = @projects_all.order("watchers_count desc")
|
||||
@s_type = 2
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
#gcm
|
||||
when '3'
|
||||
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
@projects=handle_project @projects_all,@project_activity_count
|
||||
@s_type = 3
|
||||
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||
#gcmend
|
||||
|
||||
else
|
||||
@s_type = 0
|
||||
@projects = @projects_all.order("created_on desc")
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -255,17 +289,76 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#gcm
|
||||
def search
|
||||
#modified by nie
|
||||
project_type = params[:project_type].to_i
|
||||
projects_all = (project_type.eql? Project::ProjectType_course) ? Project.course_entities : Project.project_entities
|
||||
@projects = projects_all.visible
|
||||
@projects = @projects.visible.like(params[:name]) if params[:name].present?
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@project_count = @projects.visible.count
|
||||
@project_pages = Paginator.new @project_count, @limit, params['page']
|
||||
@offset ||= @project_pages.offset
|
||||
@projects = @projects.visible.offset(@offset).limit(@limit).all
|
||||
@projects_all = @projects.visible.like(params[:name]) if params[:name].present?
|
||||
|
||||
@project_count = @projects_all.count
|
||||
@project_pages = Paginator.new @project_count, per_page_option, params['page']
|
||||
|
||||
#gcm activity count
|
||||
|
||||
@project_activity_count=Hash.new
|
||||
# count initialize
|
||||
@projects_all.each do |project|
|
||||
@project_activity_count[project.id]=0
|
||||
end
|
||||
|
||||
#@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
||||
|
||||
#gcm end
|
||||
|
||||
|
||||
case params[:project_sort_type]
|
||||
when '0'
|
||||
@projects = @projects_all.order("created_on desc")
|
||||
@s_type = 0
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
when '1'
|
||||
@projects = @projects_all.order("course_ac_para desc")
|
||||
@s_type = 1
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
when '2'
|
||||
@projects = @projects_all.order("watchers_count desc")
|
||||
@s_type = 2
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
when '3'
|
||||
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
|
||||
@project_activity_count=get_project_activity @projects_all,@project_activity_count_array #gcm
|
||||
@projects=handle_project @projects_all,@project_activity_count
|
||||
@s_type = 3
|
||||
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||
|
||||
else
|
||||
@s_type = 0
|
||||
@projects = @projects_all.order("created_on desc")
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
#gcmend
|
||||
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base'
|
||||
|
@ -285,6 +378,38 @@ class ProjectsController < ApplicationController
|
|||
}
|
||||
end
|
||||
end
|
||||
#gcmend
|
||||
|
||||
# def search
|
||||
# #modified by nie
|
||||
# project_type = params[:project_type].to_i
|
||||
# projects_all = (project_type.eql? Project::ProjectType_course) ? Project.course_entities : Project.project_entities
|
||||
# @projects = projects_all.visible
|
||||
# @projects = @projects.visible.like(params[:name]) if params[:name].present?
|
||||
# @offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
# @project_count = @projects.visible.count
|
||||
# @project_pages = Paginator.new @project_count, @limit, params['page']
|
||||
# @offset ||= @project_pages.offset
|
||||
# @projects = @projects.visible.offset(@offset).limit(@limit).all
|
||||
# respond_to do |format|
|
||||
# format.html {
|
||||
# render :layout => 'base'
|
||||
# scope = Project
|
||||
# unless params[:closed]
|
||||
# scope = scope.active
|
||||
# end
|
||||
# }
|
||||
# format.api {
|
||||
# # @offset, @limit = api_offset_and_limit
|
||||
# # @project_count = Project.visible.count
|
||||
# # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
||||
# }
|
||||
# format.atom {
|
||||
# projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||
# render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
||||
# }
|
||||
# end
|
||||
# end
|
||||
|
||||
# added by fq
|
||||
def new_join
|
||||
|
@ -953,7 +1078,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
#file_count
|
||||
Attachment.where(container_id: @project_ids).where("container_type='Project' AND created_on>?",date_from).each do |attachment|
|
||||
Attachment.where(container_id: @project_ids, container_type: Project).where("created_on>?",date_from).each do |attachment|
|
||||
activities[attachment.container_id]+=1
|
||||
end
|
||||
|
||||
|
@ -969,7 +1094,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
#feedbackc_count
|
||||
JournalsForMessage.where(jour_id: @project_ids).each do |jourformess|
|
||||
JournalsForMessage.where(jour_id: @project_ids, jour_type: Project).each do |jourformess|
|
||||
activities[jourformess.jour_id]+=1
|
||||
end
|
||||
|
||||
|
@ -988,17 +1113,16 @@ class ProjectsController < ApplicationController
|
|||
|
||||
#gcm
|
||||
def handle_project projects,activities
|
||||
@project_activity_count_array=activities.values()
|
||||
project_activity_count_array=activities.values()
|
||||
|
||||
project_all_array=[]
|
||||
project_array=[]
|
||||
i=0;
|
||||
projects.each do |project|
|
||||
id=project.id
|
||||
@project_all_array[i]=project
|
||||
project_array[i]=project
|
||||
i=i+1
|
||||
end
|
||||
|
||||
projects=desc_sort_course_by_avtivity(@project_activity_count_array,project_all_array)
|
||||
projects=desc_sort_course_by_avtivity(project_activity_count_array,project_array)
|
||||
|
||||
return projects
|
||||
end
|
||||
|
@ -1017,21 +1141,6 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
return projects
|
||||
|
||||
|
||||
|
||||
# len=activity_count.length
|
||||
# for i in 0...(len-1) do
|
||||
# for j in 0...(len-i-1) do
|
||||
# if activity_count[j]>activity_count[j+1] do
|
||||
# count_temp=activity_count[j]
|
||||
|
||||
# activity_count[j]=activity_count[j+1]
|
||||
# activity_count[j+1]=count_temp
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#desc_sort_course_by_avtivity(@project_ids,@project_activity_count_array,@projects_all)
|
||||
end
|
||||
#gcmend
|
||||
|
||||
|
|
Loading…
Reference in New Issue