admin页面中问题追踪项相关错误(课程、项目分离此处代码未改导致的问题)、项目列表中项目提交次数改为从数据库中读取(运行bundle exec rake project_score:calculate统计项目提交次数)
This commit is contained in:
parent
e63be10680
commit
cb8b0e0f41
|
@ -502,45 +502,7 @@ class CoursesController < ApplicationController
|
||||||
|
|
||||||
end
|
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
|
def toggleCourse
|
||||||
@course_prefs = Course.find_by_extra(@course.extra)
|
@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, :except => :index
|
||||||
before_filter :require_admin_or_api_request, :only => :index
|
before_filter :require_admin_or_api_request, :only => :index
|
||||||
accept_api_auth :index
|
accept_api_auth :index
|
||||||
|
include CoursesHelper
|
||||||
def index
|
def index
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
@ -37,8 +37,13 @@ class TrackersController < ApplicationController
|
||||||
def new
|
def new
|
||||||
@tracker ||= Tracker.new(params[:tracker])
|
@tracker ||= Tracker.new(params[:tracker])
|
||||||
@trackers = Tracker.sorted.all
|
@trackers = Tracker.sorted.all
|
||||||
@projects = Project.all
|
@projects = Project.where("project_type = #{Project::ProjectType_project}").all
|
||||||
@courses = Course.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
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -58,7 +63,8 @@ class TrackersController < ApplicationController
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@tracker ||= Tracker.find(params[:id])
|
@tracker ||= Tracker.find(params[:id])
|
||||||
@projects = Project.all
|
@projects = Project.where("project_type = #{Project::ProjectType_project}").all
|
||||||
|
@courses = Course.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
@ -480,4 +480,45 @@ module CoursesHelper
|
||||||
type
|
type
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -71,11 +71,24 @@ module ProjectScoreHelper
|
||||||
pss = ProjectScore.where("project_id = '#{project.id}'")
|
pss = ProjectScore.where("project_id = '#{project.id}'")
|
||||||
if pss.nil? || pss.count == 0
|
if pss.nil? || pss.count == 0
|
||||||
ps = ProjectScore.new
|
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.score = result
|
||||||
ps.project = project
|
ps.project = project
|
||||||
ps.save
|
ps.save
|
||||||
else
|
else
|
||||||
ps = pss.first
|
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.score = result
|
||||||
ps.save
|
ps.save
|
||||||
end
|
end
|
||||||
|
@ -95,4 +108,15 @@ module ProjectScoreHelper
|
||||||
end
|
end
|
||||||
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
|
end
|
|
@ -32,6 +32,7 @@ class Tracker < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
has_and_belongs_to_many :projects
|
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'
|
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
|
acts_as_list
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 40%;text-align: right;font-size: 17px;color: rgb(17, 102, 153)">
|
<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 -->
|
<!-- @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>
|
||||||
<td style="width: 60%;text-align: left">
|
<td style="width: 60%;text-align: left">
|
||||||
<%= content_tag('span', l(:label_commit_on)) %>
|
<%= content_tag('span', l(:label_commit_on)) %>
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="add-info">
|
<div class="add-info-project">
|
||||||
<div class="main-language">
|
<div class="main-language">
|
||||||
<!-- added by huang -->
|
<!-- added by huang -->
|
||||||
<% if(@project.project_type==1)%>
|
<% if(@project.project_type==1)%>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<% i += 1 %>
|
<% i += 1 %>
|
||||||
<% end %>
|
<% 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 %>
|
<% else %>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= error_messages_for 'tracker' %>
|
<%= error_messages_for 'tracker' %>
|
||||||
|
|
||||||
<div class="splitcontentleft">
|
<div> <!-- class="splitcontentleft" -->
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<!--[form:tracker]-->
|
<!--[form:tracker]-->
|
||||||
<p><%= f.text_field :name, :required => true %></p>
|
<p><%= f.text_field :name, :required => true %></p>
|
||||||
|
@ -39,14 +39,27 @@
|
||||||
<%= submit_tag l(@tracker.new_record? ? :button_create : :button_save) %>
|
<%= submit_tag l(@tracker.new_record? ? :button_create : :button_save) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="splitcontentright">
|
<div><!--class="splitcontentright" -->
|
||||||
<% if @projects.any? %>
|
<% if @projects.any? %>
|
||||||
<fieldset class="box" id="tracker_project_ids"><legend><%= l(:label_project_plural) %></legend>
|
<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|
|
<%= 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))
|
content_tag('label', check_box_tag('tracker[project_ids][]', p.id, @tracker.projects.include?(p), :id => nil) + ' ' + h(p))
|
||||||
end %>
|
end %>
|
||||||
|
</div>
|
||||||
<%= hidden_field_tag('tracker[project_ids][]', '', :id => nil) %>
|
<%= hidden_field_tag('tracker[project_ids][]', '', :id => nil) %>
|
||||||
|
|
||||||
<p><%= check_all_links 'tracker_project_ids' %></p>
|
<p><%= check_all_links 'tracker_project_ids' %></p>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<% end %>
|
<% 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>
|
</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.
|
# 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|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -441,10 +441,10 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "sort_type"
|
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_width", :default => 107
|
||||||
t.integer "image_height", :default => 63
|
t.integer "image_height", :default => 63
|
||||||
|
t.integer "show_course", :default => 1
|
||||||
|
t.integer "show_contest", :default => 1
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "forums", :force => true do |t|
|
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|
|
create_table "project_scores", :force => true do |t|
|
||||||
t.string "project_id"
|
t.string "project_id"
|
||||||
t.integer "score"
|
t.integer "score"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_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
|
end
|
||||||
|
|
||||||
create_table "project_statuses", :force => true do |t|
|
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; }
|
#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%; }
|
.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;}
|
#related-issues li img {vertical-align:middle;}
|
||||||
|
|
||||||
ul.properties {padding:0; font-size: 0.9em; color: #777;}
|
ul.properties {padding:0; font-size: 0.9em; color: #777;}
|
||||||
|
|
|
@ -1071,14 +1071,14 @@ overflow: hidden;
|
||||||
.information {
|
.information {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-left: 690px;
|
margin-left: 690px;
|
||||||
float: left;
|
/*float: left;*/
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 280px;
|
width: 280px;
|
||||||
font-family: '微软雅黑',helvetica,arial,sans-serif; /*modify by men*/
|
font-family: '微软雅黑',helvetica,arial,sans-serif; /*modify by men*/
|
||||||
color: rgb(0, 0, 0);
|
color: rgb(0, 0, 0);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
position: absolute;
|
/*position: absolute;*/
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
a.project {
|
a.project {
|
||||||
|
@ -1216,6 +1216,15 @@ p.stats {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.add-info-project {
|
||||||
|
/*float: left;*/
|
||||||
|
margin-top: 0px;
|
||||||
|
height: 20px;
|
||||||
|
width: 908px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.main-language {
|
.main-language {
|
||||||
float: left;
|
float: left;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
|
|
Loading…
Reference in New Issue