admin页面中问题追踪项相关错误(课程、项目分离此处代码未改导致的问题)、项目列表中项目提交次数改为从数据库中读取(运行bundle exec rake project_score:calculate统计项目提交次数)
This commit is contained in:
parent
e63be10680
commit
cb8b0e0f41
|
@ -502,45 +502,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
def get_course_activity courses, activities
|
||||
@course_ids=activities.keys()
|
||||
|
||||
days = Setting.activity_days_default.to_i
|
||||
date_to ||= Date.today + 1
|
||||
date_from = date_to - days-1.years
|
||||
|
||||
#file_count
|
||||
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
||||
activities[attachment.container_id]+=1
|
||||
end
|
||||
|
||||
#message_count
|
||||
Board.where(course_id: @course_ids).each do |board|
|
||||
# activities[board.course_id]+=1
|
||||
activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
|
||||
end
|
||||
|
||||
#news
|
||||
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
||||
activities[news.course_id]+=1
|
||||
end
|
||||
|
||||
#feedbackc_count
|
||||
JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
|
||||
activities[jourformess.jour_id]+=1
|
||||
end
|
||||
|
||||
#activities!=0
|
||||
i=0;
|
||||
courses.each do |course|
|
||||
id=course.id
|
||||
if activities[id]==0
|
||||
activities[id]=1
|
||||
end
|
||||
end
|
||||
|
||||
return activities
|
||||
end
|
||||
|
||||
def toggleCourse
|
||||
@course_prefs = Course.find_by_extra(@course.extra)
|
||||
|
|
|
@ -21,7 +21,7 @@ class TrackersController < ApplicationController
|
|||
before_filter :require_admin, :except => :index
|
||||
before_filter :require_admin_or_api_request, :only => :index
|
||||
accept_api_auth :index
|
||||
|
||||
include CoursesHelper
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -37,8 +37,13 @@ class TrackersController < ApplicationController
|
|||
def new
|
||||
@tracker ||= Tracker.new(params[:tracker])
|
||||
@trackers = Tracker.sorted.all
|
||||
@projects = Project.all
|
||||
@projects = Project.where("project_type = #{Project::ProjectType_project}").all
|
||||
@courses = Course.all
|
||||
@course_activity_count=Hash.new
|
||||
@courses.each do |course|
|
||||
@course_activity_count[course.id]=0
|
||||
end
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -58,7 +63,8 @@ class TrackersController < ApplicationController
|
|||
|
||||
def edit
|
||||
@tracker ||= Tracker.find(params[:id])
|
||||
@projects = Project.all
|
||||
@projects = Project.where("project_type = #{Project::ProjectType_project}").all
|
||||
@courses = Course.all
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -480,4 +480,45 @@ module CoursesHelper
|
|||
type
|
||||
end
|
||||
|
||||
#获取课程动态
|
||||
def get_course_activity courses, activities
|
||||
@course_ids=activities.keys()
|
||||
|
||||
days = Setting.activity_days_default.to_i
|
||||
date_to ||= Date.today + 1
|
||||
date_from = date_to - days-1.years
|
||||
|
||||
#file_count
|
||||
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
||||
activities[attachment.container_id]+=1
|
||||
end
|
||||
|
||||
#message_count
|
||||
Board.where(course_id: @course_ids).each do |board|
|
||||
# activities[board.course_id]+=1
|
||||
activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
|
||||
end
|
||||
|
||||
#news
|
||||
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
||||
activities[news.course_id]+=1
|
||||
end
|
||||
|
||||
#feedbackc_count
|
||||
JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
|
||||
activities[jourformess.jour_id]+=1
|
||||
end
|
||||
|
||||
#activities!=0
|
||||
i=0;
|
||||
courses.each do |course|
|
||||
id=course.id
|
||||
if activities[id]==0
|
||||
activities[id]=1
|
||||
end
|
||||
end
|
||||
|
||||
return activities
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -71,11 +71,24 @@ module ProjectScoreHelper
|
|||
pss = ProjectScore.where("project_id = '#{project.id}'")
|
||||
if pss.nil? || pss.count == 0
|
||||
ps = ProjectScore.new
|
||||
ps.issue_num = issue_num(project)
|
||||
ps.board_message_num = board_message_num(project)
|
||||
ps.changeset_num = changesets_num(project)
|
||||
ps.documents_num = documents_num(project)
|
||||
ps.issue_journal_num = issue_journal_num(project)
|
||||
ps.news_num = news_num(project)
|
||||
|
||||
ps.score = result
|
||||
ps.project = project
|
||||
ps.save
|
||||
else
|
||||
ps = pss.first
|
||||
ps.issue_num = issue_num(project)
|
||||
ps.board_message_num = board_message_num(project)
|
||||
ps.changeset_num = changesets_num(project)
|
||||
ps.documents_num = documents_num(project)
|
||||
ps.issue_journal_num = issue_journal_num(project)
|
||||
ps.news_num = news_num(project)
|
||||
ps.score = result
|
||||
ps.save
|
||||
end
|
||||
|
@ -95,4 +108,15 @@ module ProjectScoreHelper
|
|||
end
|
||||
end
|
||||
|
||||
def get_project_score project
|
||||
pss = ProjectScore.where("project_id = '#{project.id}'")
|
||||
ps = nil
|
||||
if pss.nil? || pss.count == 0
|
||||
ps = nil
|
||||
else
|
||||
ps = pss.first
|
||||
end
|
||||
ps
|
||||
end
|
||||
|
||||
end
|
|
@ -32,6 +32,7 @@ class Tracker < ActiveRecord::Base
|
|||
end
|
||||
|
||||
has_and_belongs_to_many :projects
|
||||
has_and_belongs_to_many :courses
|
||||
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
|
||||
acts_as_list
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<tr>
|
||||
<td style="width: 40%;text-align: right;font-size: 17px;color: rgb(17, 102, 153)">
|
||||
<!-- @project.repository.nil? || @project.project_status.nil? ? '0' : @project.project_status.changesets_count -->
|
||||
<strong><%= content_tag('span', "#{changesets_num(@project)}", :class => "info") %></strong>
|
||||
<strong><%= content_tag('span', "#{get_project_score(@project).nil? ? 0:get_project_score(@project).changeset_num}", :class => "info") %></strong>
|
||||
</td>
|
||||
<td style="width: 60%;text-align: left">
|
||||
<%= content_tag('span', l(:label_commit_on)) %>
|
||||
|
@ -87,7 +87,7 @@
|
|||
<% end %>
|
||||
|
||||
</div>
|
||||
<div class="add-info">
|
||||
<div class="add-info-project">
|
||||
<div class="main-language">
|
||||
<!-- added by huang -->
|
||||
<% if(@project.project_type==1)%>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<% i += 1 %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to l(:label_more_tags), :action => "show", :id => obj.id %>
|
||||
<%= link_to l(:label_more_tags),:controller => "tags", :action => "show", :id => obj.id %>
|
||||
|
||||
<% else %>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%= error_messages_for 'tracker' %>
|
||||
|
||||
<div class="splitcontentleft">
|
||||
<div> <!-- class="splitcontentleft" -->
|
||||
<div class="box tabular">
|
||||
<!--[form:tracker]-->
|
||||
<p><%= f.text_field :name, :required => true %></p>
|
||||
|
@ -39,14 +39,27 @@
|
|||
<%= submit_tag l(@tracker.new_record? ? :button_create : :button_save) %>
|
||||
</div>
|
||||
|
||||
<div class="splitcontentright">
|
||||
<div><!--class="splitcontentright" -->
|
||||
<% if @projects.any? %>
|
||||
<fieldset class="box" id="tracker_project_ids"><legend><%= l(:label_project_plural) %></legend>
|
||||
<div style="overflow: scroll; height: 300px; width: 680px;">
|
||||
<%= render_project_nested_lists(@projects) do |p|
|
||||
content_tag('label', check_box_tag('tracker[project_ids][]', p.id, @tracker.projects.include?(p), :id => nil) + ' ' + h(p))
|
||||
end %>
|
||||
</div>
|
||||
<%= hidden_field_tag('tracker[project_ids][]', '', :id => nil) %>
|
||||
|
||||
<p><%= check_all_links 'tracker_project_ids' %></p>
|
||||
|
||||
</fieldset>
|
||||
<% end %>
|
||||
<!-- <#% if @courses.any? %>
|
||||
<fieldset class="box" id="tracker_course_ids"><legend><#%= l(:label_course_all) %></legend>
|
||||
<#%= render_course_nested_lists(@courses) do |p|
|
||||
content_tag('label', check_box_tag('tracker[course_ids][]', p.id, @tracker.projects.include?(p), :id => nil) + ' ' + h(p))
|
||||
end %>
|
||||
<#%= hidden_field_tag('tracker[course_ids][]', '', :id => nil) %>
|
||||
<p><#%= check_all_links 'tracker_course_ids' %></p>
|
||||
</fieldset>
|
||||
<#% end %> -->
|
||||
</div>
|
||||
|
|
16
db/schema.rb
16
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140814062455) do
|
||||
ActiveRecord::Schema.define(:version => 20140826072838) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -441,10 +441,10 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
|
|||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "sort_type"
|
||||
t.integer "show_course", :default => 1
|
||||
t.integer "show_contest", :default => 1
|
||||
t.integer "image_width", :default => 107
|
||||
t.integer "image_height", :default => 63
|
||||
t.integer "show_course", :default => 1
|
||||
t.integer "show_contest", :default => 1
|
||||
end
|
||||
|
||||
create_table "forums", :force => true do |t|
|
||||
|
@ -793,8 +793,14 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
|
|||
create_table "project_scores", :force => true do |t|
|
||||
t.string "project_id"
|
||||
t.integer "score"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "issue_num", :default => 0
|
||||
t.integer "issue_journal_num", :default => 0
|
||||
t.integer "news_num", :default => 0
|
||||
t.integer "documents_num", :default => 0
|
||||
t.integer "changeset_num", :default => 0
|
||||
t.integer "board_message_num", :default => 0
|
||||
end
|
||||
|
||||
create_table "project_statuses", :force => true do |t|
|
||||
|
|
|
@ -1725,8 +1725,8 @@ ul.projects li {list-style-type:none;
|
|||
#projects-index ul.projects div.root a.project {font-family:'微软雅黑', "Trebuchet MS", Verdana, sans-serif; font-weight: bold; font-size: 14px; margin: 0 0 10px 0; }
|
||||
.my-project { padding-left: 18px; background: url(../images/fav.png) no-repeat 0 50%; }
|
||||
|
||||
#notified-projects ul, #tracker_project_ids ul {max-height:250px; overflow-y:auto;}
|
||||
|
||||
#notified-projects ul{max-height:250px; overflow-y:auto;}
|
||||
#tracker_project_ids ul {max-height:250px; /*overflow-y:auto;*/}
|
||||
#related-issues li img {vertical-align:middle;}
|
||||
|
||||
ul.properties {padding:0; font-size: 0.9em; color: #777;}
|
||||
|
|
|
@ -1071,14 +1071,14 @@ overflow: hidden;
|
|||
.information {
|
||||
margin-top: 20px;
|
||||
margin-left: 690px;
|
||||
float: left;
|
||||
/*float: left;*/
|
||||
height: auto;
|
||||
width: 280px;
|
||||
font-family: '微软雅黑',helvetica,arial,sans-serif; /*modify by men*/
|
||||
color: rgb(0, 0, 0);
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
position: absolute;
|
||||
/*position: absolute;*/
|
||||
}
|
||||
/*
|
||||
a.project {
|
||||
|
@ -1216,6 +1216,15 @@ p.stats {
|
|||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.add-info-project {
|
||||
/*float: left;*/
|
||||
margin-top: 0px;
|
||||
height: 20px;
|
||||
width: 908px;
|
||||
margin-bottom: 5px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.main-language {
|
||||
float: left;
|
||||
height: 18px;
|
||||
|
|
Loading…
Reference in New Issue