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
|
@project_activity_count=Hash.new
|
||||||
|
|
||||||
@projects_all.each do |project|
|
@projects_all.each do |project|
|
||||||
@project_activity_count[project.id]=1
|
@project_activity_count[project.id]=0
|
||||||
end
|
end
|
||||||
project_ids=@project_activity_count.keys()
|
@project_ids=@project_activity_count.keys()
|
||||||
|
|
||||||
days = Setting.activity_days_default.to_i
|
days = Setting.activity_days_default.to_i
|
||||||
date_to ||= Date.today + 1
|
date_to ||= Date.today + 1
|
||||||
|
@ -251,47 +251,67 @@ class ProjectsController < ApplicationController
|
||||||
#gcm approach 2
|
#gcm approach 2
|
||||||
|
|
||||||
#issue_count
|
#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.to_s]+=1
|
||||||
@project_activity_count[issue.project_id]+=issue.journals.where("created_on>?",date_from).count
|
@project_activity_count[issue.project_id]+=issue.journals.where("created_on>?",date_from).count
|
||||||
end
|
end
|
||||||
|
|
||||||
#repository_count
|
#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.to_s]+=1
|
||||||
@project_activity_count[repository.project_id]+=repository.changesets.where("committed_on>?",date_from).count
|
@project_activity_count[repository.project_id]+=repository.changesets.where("committed_on>?",date_from).count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
#news_count
|
#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
|
@project_activity_count[news.project_id]+=1
|
||||||
end
|
end
|
||||||
|
|
||||||
#document_count
|
#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
|
@project_activity_count[document.project_id]+=1
|
||||||
end
|
end
|
||||||
|
|
||||||
#file_count
|
#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
|
@project_activity_count[attachment.container_id]+=1
|
||||||
end
|
end
|
||||||
|
|
||||||
#message_count
|
#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]+=1
|
||||||
@project_activity_count[board.project_id]+=board.messages.where("updated_on>?",date_from).count
|
@project_activity_count[board.project_id]+=board.messages.where("updated_on>?",date_from).count
|
||||||
end
|
end
|
||||||
|
|
||||||
#time_entry_count
|
#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
|
@project_activity_count[timeentry.project_id]+=1
|
||||||
end
|
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()
|
@project_activity_count_array=@project_activity_count.values()
|
||||||
max_ac=@project_activity_count_array.max
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#gcm end
|
#gcm end
|
||||||
|
|
||||||
|
@ -300,17 +320,28 @@ class ProjectsController < ApplicationController
|
||||||
when '0'
|
when '0'
|
||||||
@projects = @projects_all.order("created_on desc")
|
@projects = @projects_all.order("created_on desc")
|
||||||
@s_type = 0
|
@s_type = 0
|
||||||
|
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||||
when '1'
|
when '1'
|
||||||
@projects = @projects_all.order("course_ac_para desc")
|
@projects = @projects_all.order("course_ac_para desc")
|
||||||
@s_type = 1
|
@s_type = 1
|
||||||
|
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||||
when '2'
|
when '2'
|
||||||
@projects = @projects_all.order("watchers_count desc")
|
@projects = @projects_all.order("watchers_count desc")
|
||||||
@s_type = 2
|
@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
|
else
|
||||||
@s_type = 0
|
@s_type = 0
|
||||||
@projects = @projects_all.order("created_on desc")
|
@projects = @projects_all.order("created_on desc")
|
||||||
|
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||||
end
|
end
|
||||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
@ -992,7 +1023,31 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
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
|
||||||
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_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_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_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
|
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_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_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_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
|
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_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_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_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
|
end
|
||||||
|
#gcmend
|
||||||
|
|
||||||
content = content_tag('ul', content)
|
content = content_tag('ul', content)
|
||||||
content_tag('div', content, :class => "tabs")
|
content_tag('div', content, :class => "tabs")
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
<% @admin = @project.project_infos%>
|
<% @admin = @project.project_infos%>
|
||||||
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
|
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
|
||||||
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
|
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
|
||||||
|
<% unless @project.course_extra.school.nil? %>
|
||||||
<%= @project.course_extra.school.name %>
|
<%= @project.course_extra.school.name %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<p >
|
<p >
|
||||||
|
|
Loading…
Reference in New Issue