add course homepage activity
This commit is contained in:
parent
daa19de51d
commit
77ea0092b7
|
@ -198,9 +198,9 @@ class ProjectsController < ApplicationController
|
|||
@project_activity_count=Hash.new
|
||||
|
||||
@projects_all.each do |project|
|
||||
@project_activity_count[project.id]=1
|
||||
@project_activity_count[project.id]=0
|
||||
end
|
||||
project_ids=@project_activity_count.keys()
|
||||
@project_ids=@project_activity_count.keys()
|
||||
|
||||
days = Setting.activity_days_default.to_i
|
||||
date_to ||= Date.today + 1
|
||||
|
@ -251,47 +251,67 @@ class ProjectsController < ApplicationController
|
|||
#gcm approach 2
|
||||
|
||||
#issue_count
|
||||
Issue.where(project_id: project_ids).where("updated_on>?",date_from).each do |issue|
|
||||
Issue.where(project_id: @project_ids).where("updated_on>?",date_from).each do |issue|
|
||||
# @project_activity_count[issue.project_id.to_s]+=1
|
||||
@project_activity_count[issue.project_id]+=issue.journals.where("created_on>?",date_from).count
|
||||
end
|
||||
|
||||
#repository_count
|
||||
Repository.where(project_id: project_ids).each do |repository|
|
||||
Repository.where(project_id: @project_ids).each do |repository|
|
||||
# @project_activity_count[repository.project_id.to_s]+=1
|
||||
@project_activity_count[repository.project_id]+=repository.changesets.where("committed_on>?",date_from).count
|
||||
end
|
||||
|
||||
|
||||
#news_count
|
||||
News.where(project_id: project_ids).where("created_on>?",date_from).each do |news|
|
||||
News.where(project_id: @project_ids).where("created_on>?",date_from).each do |news|
|
||||
@project_activity_count[news.project_id]+=1
|
||||
end
|
||||
|
||||
#document_count
|
||||
Document.where(project_id: project_ids).where("created_on>?",date_from).each do |document|
|
||||
Document.where(project_id: @project_ids).where("created_on>?",date_from).each do |document|
|
||||
@project_activity_count[document.project_id]+=1
|
||||
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).where("container_type='Project' AND created_on>?",date_from).each do |attachment|
|
||||
@project_activity_count[attachment.container_id]+=1
|
||||
end
|
||||
|
||||
#message_count
|
||||
Board.where(project_id: project_ids).take(1) do |board|
|
||||
Board.where(project_id: @project_ids).each do |board|
|
||||
# @project_activity_count[board.project_id]+=1
|
||||
@project_activity_count[board.project_id]+=board.messages.where("updated_on>?",date_from).count
|
||||
end
|
||||
|
||||
#time_entry_count
|
||||
TimeEntry.where(project_id: project_ids).where("updated_on>?",date_from).each do |timeentry|
|
||||
TimeEntry.where(project_id: @project_ids).where("updated_on>?",date_from).each do |timeentry|
|
||||
@project_activity_count[timeentry.project_id]+=1
|
||||
end
|
||||
|
||||
#feedbackc_count
|
||||
JournalsForMessage.where(jour_id: @project_ids).each do |jourformess|
|
||||
@project_activity_count[jourformess.jour_id]+=1
|
||||
end
|
||||
|
||||
#@project_activity_count!=0
|
||||
@project_all_array=[]
|
||||
i=0;
|
||||
@projects_all.each do |project|
|
||||
id=project.id
|
||||
@project_all_array[i]=project
|
||||
if @project_activity_count[id]==0
|
||||
@project_activity_count[id]=1
|
||||
end
|
||||
i=i+1
|
||||
end
|
||||
|
||||
|
||||
@project_activity_count_array=@project_activity_count.values()
|
||||
max_ac=@project_activity_count_array.max
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#gcm end
|
||||
|
||||
|
@ -300,17 +320,28 @@ class ProjectsController < ApplicationController
|
|||
when '0'
|
||||
@projects = @projects_all.order("created_on desc")
|
||||
@s_type = 0
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
when '1'
|
||||
@projects = @projects_all.order("course_ac_para desc")
|
||||
@s_type = 1
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
when '2'
|
||||
@projects = @projects_all.order("watchers_count desc")
|
||||
@s_type = 2
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
#gcm
|
||||
when '3'
|
||||
@projects=desc_sort_course_by_avtivity(@project_ids,@project_activity_count_array,@project_all_array)
|
||||
@s_type = 3
|
||||
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||
#gcmend
|
||||
|
||||
else
|
||||
@s_type = 0
|
||||
@projects = @projects_all.order("created_on desc")
|
||||
end
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -992,7 +1023,31 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def desc_sort_course_by_avtivity(projects,ids,activities)
|
||||
def desc_sort_course_by_avtivity(ids,activity_count,projects)
|
||||
return projects if activity_count.size<2
|
||||
(activity_count.size-2).downto(0) do |i|
|
||||
(0..i).each do |j|
|
||||
if activity_count[j]<activity_count[j+1]
|
||||
projects[j],projects[j+1]=projects[j+1],projects[j]
|
||||
activity_count[j],activity_count[j+1]=activity_count[j+1],activity_count[j]
|
||||
end
|
||||
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
|
||||
end
|
||||
|
|
|
@ -69,18 +69,29 @@ module ProjectsHelper
|
|||
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
|
||||
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type)))
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type)))
|
||||
|
||||
when 2
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
|
||||
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type)))
|
||||
|
||||
#gcm
|
||||
when 3
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
|
||||
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
end
|
||||
#gcmend
|
||||
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
<% @admin = @project.project_infos%>
|
||||
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
|
||||
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
|
||||
<% unless @project.course_extra.school.nil? %>
|
||||
<%= @project.course_extra.school.name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</p>
|
||||
<p >
|
||||
<%= content_tag('div', "#{l(:field_teacher_name)}:", :class => "info course-font teacher") %>
|
||||
|
|
Loading…
Reference in New Issue