revise project index,course,search
This commit is contained in:
parent
b542f8072d
commit
e9bd8a8f3e
|
@ -200,113 +200,13 @@ class ProjectsController < ApplicationController
|
||||||
@projects_all.each do |project|
|
@projects_all.each do |project|
|
||||||
@project_activity_count[project.id]=0
|
@project_activity_count[project.id]=0
|
||||||
end
|
end
|
||||||
@project_ids=@project_activity_count.keys()
|
|
||||||
|
|
||||||
days = Setting.activity_days_default.to_i
|
@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
||||||
date_to ||= Date.today + 1
|
|
||||||
date_from = date_to - days-1.years
|
|
||||||
|
|
||||||
#approach 1
|
|
||||||
=begin
|
|
||||||
|
|
||||||
@projects_all.each do |project|
|
|
||||||
#issue_count
|
|
||||||
issues=Issue.where("project_id=?",project.id)
|
|
||||||
issue_count=0
|
|
||||||
issues.each do |issue|
|
|
||||||
issue_count+=issue.journals.count
|
|
||||||
end
|
|
||||||
|
|
||||||
#repository_count
|
|
||||||
repositories=Repository.where("project_id=?",project.id)
|
|
||||||
repository_count=0
|
|
||||||
repositories.each do |repository|
|
|
||||||
repository_count+=repository.changesets.count
|
|
||||||
end
|
|
||||||
|
|
||||||
#news_count
|
|
||||||
news_count=News.where("project_id=?",project.id).count
|
|
||||||
#document_count
|
|
||||||
document_count=Document.where("project_id=?",project.id).count
|
|
||||||
#file_count
|
|
||||||
file_count=Attachment.where("container_type='Project' AND container_id=?",project.id).count
|
|
||||||
|
|
||||||
#message_count
|
|
||||||
boards=Board.where("project_id=?",project.id)
|
|
||||||
message_count=0
|
|
||||||
boards.each do |board|
|
|
||||||
message_count+=board.messages.count
|
|
||||||
end
|
|
||||||
|
|
||||||
#time_entry_count
|
|
||||||
time_entry_count=TimeEntry.where("project_id=?",project.id).count
|
|
||||||
|
|
||||||
#sum
|
|
||||||
@project_activity_count[project.id.to_s]=issue_count+repository_count+news_count+document_count+file_count+message_count+time_entry_count
|
|
||||||
|
|
||||||
end
|
|
||||||
=end
|
|
||||||
#gcm
|
|
||||||
|
|
||||||
#gcm approach 2
|
|
||||||
|
|
||||||
#issue_count
|
|
||||||
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|
|
|
||||||
# @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
|
#movebegin
|
||||||
News.where(project_id: @project_ids).where("created_on>?",date_from).each do |news|
|
|
||||||
@project_activity_count[news.project_id]+=1
|
|
||||||
end
|
|
||||||
|
|
||||||
#document_count
|
#moveend
|
||||||
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|
|
|
||||||
@project_activity_count[attachment.container_id]+=1
|
|
||||||
end
|
|
||||||
|
|
||||||
#message_count
|
|
||||||
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|
|
|
||||||
@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()
|
|
||||||
|
|
||||||
#gcm end
|
#gcm end
|
||||||
|
|
||||||
|
@ -327,7 +227,8 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
#gcm
|
#gcm
|
||||||
when '3'
|
when '3'
|
||||||
@projects=desc_sort_course_by_avtivity(@project_ids,@project_activity_count_array,@project_all_array)
|
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
|
||||||
|
@projects=handle_project @projects_all,@project_activity_count
|
||||||
@s_type = 3
|
@s_type = 3
|
||||||
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||||
#gcmend
|
#gcmend
|
||||||
|
@ -1018,7 +919,94 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def desc_sort_course_by_avtivity(ids,activity_count,projects)
|
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
def get_project_activity projects,activities
|
||||||
|
@project_ids=activities.keys()
|
||||||
|
|
||||||
|
days = Setting.activity_days_default.to_i
|
||||||
|
date_to ||= Date.today + 1
|
||||||
|
date_from = date_to - days-1.years
|
||||||
|
|
||||||
|
#issue_count
|
||||||
|
Issue.where(project_id: @project_ids).where("updated_on>?",date_from).each do |issue|
|
||||||
|
# activities[issue.project_id.to_s]+=1
|
||||||
|
activities[issue.project_id]+=issue.journals.where("created_on>?",date_from).count
|
||||||
|
end
|
||||||
|
|
||||||
|
#repository_count
|
||||||
|
Repository.where(project_id: @project_ids).each do |repository|
|
||||||
|
# activities[repository.project_id.to_s]+=1
|
||||||
|
activities[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|
|
||||||
|
activities[news.project_id]+=1
|
||||||
|
end
|
||||||
|
|
||||||
|
#document_count
|
||||||
|
Document.where(project_id: @project_ids).where("created_on>?",date_from).each do |document|
|
||||||
|
activities[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|
|
||||||
|
activities[attachment.container_id]+=1
|
||||||
|
end
|
||||||
|
|
||||||
|
#message_count
|
||||||
|
Board.where(project_id: @project_ids).each do |board|
|
||||||
|
# activities[board.project_id]+=1
|
||||||
|
activities[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|
|
||||||
|
activities[timeentry.project_id]+=1
|
||||||
|
end
|
||||||
|
|
||||||
|
#feedbackc_count
|
||||||
|
JournalsForMessage.where(jour_id: @project_ids).each do |jourformess|
|
||||||
|
activities[jourformess.jour_id]+=1
|
||||||
|
end
|
||||||
|
|
||||||
|
#activities!=0
|
||||||
|
i=0;
|
||||||
|
projects.each do |project|
|
||||||
|
id=project.id
|
||||||
|
if activities[id]==0
|
||||||
|
activities[id]=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return activities
|
||||||
|
end
|
||||||
|
#gcmend
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
def handle_project projects,activities
|
||||||
|
@project_activity_count_array=activities.values()
|
||||||
|
|
||||||
|
project_all_array=[]
|
||||||
|
i=0;
|
||||||
|
projects.each do |project|
|
||||||
|
id=project.id
|
||||||
|
@project_all_array[i]=project
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
|
|
||||||
|
projects=desc_sort_course_by_avtivity(@project_activity_count_array,project_all_array)
|
||||||
|
|
||||||
|
return projects
|
||||||
|
end
|
||||||
|
#gcmend
|
||||||
|
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
def desc_sort_course_by_avtivity(activity_count,projects)
|
||||||
return projects if activity_count.size<2
|
return projects if activity_count.size<2
|
||||||
(activity_count.size-2).downto(0) do |i|
|
(activity_count.size-2).downto(0) do |i|
|
||||||
(0..i).each do |j|
|
(0..i).each do |j|
|
||||||
|
@ -1045,4 +1033,6 @@ class ProjectsController < ApplicationController
|
||||||
# end
|
# end
|
||||||
#desc_sort_course_by_avtivity(@project_ids,@project_activity_count_array,@projects_all)
|
#desc_sort_course_by_avtivity(@project_ids,@project_activity_count_array,@projects_all)
|
||||||
end
|
end
|
||||||
|
#gcmend
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<!--gcm-->
|
<!--gcm-->
|
||||||
<p class="stats">
|
<p class="stats">
|
||||||
|
|
||||||
<%= content_tag('span', link_to("#{@project_activity_count[@project.id]}", member_project_path(@project)), :class => "info") %>
|
<%= content_tag('span', link_to("#{@project_activity_count[@project.id]}", project_path(@project)), :class => "info") %>
|
||||||
<%= content_tag('span', l(:label_x_activity, :count => @project_activity_count[@project.id])) %>
|
<%= content_tag('span', l(:label_x_activity, :count => @project_activity_count[@project.id])) %>
|
||||||
</p>
|
</p>
|
||||||
<!--gcm-->
|
<!--gcm-->
|
||||||
|
|
Loading…
Reference in New Issue