From cb8b0e0f416532515ff38c0587ede3a575179b1c Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 26 Aug 2014 16:07:17 +0800 Subject: [PATCH] =?UTF-8?q?admin=E9=A1=B5=E9=9D=A2=E4=B8=AD=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E8=BF=BD=E8=B8=AA=E9=A1=B9=E7=9B=B8=E5=85=B3=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=88=E8=AF=BE=E7=A8=8B=E3=80=81=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=88=86=E7=A6=BB=E6=AD=A4=E5=A4=84=E4=BB=A3=E7=A0=81=E6=9C=AA?= =?UTF-8?q?=E6=94=B9=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=89?= =?UTF-8?q?=E3=80=81=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=E4=B8=AD=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=8F=90=E4=BA=A4=E6=AC=A1=E6=95=B0=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E4=BB=8E=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=EF=BC=88=E8=BF=90=E8=A1=8Cbundle=20exec=20rake=20project=5Fsco?= =?UTF-8?q?re:calculate=E7=BB=9F=E8=AE=A1=E9=A1=B9=E7=9B=AE=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=AC=A1=E6=95=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 38 ----------------- app/controllers/trackers_controller.rb | 12 ++++-- app/helpers/courses_helper.rb | 41 +++++++++++++++++++ app/helpers/project_score_helper.rb | 24 +++++++++++ app/models/tracker.rb | 1 + app/views/projects/_project.html.erb | 4 +- app/views/tags/_tag_name.html.erb | 2 +- app/views/trackers/_form.html.erb | 17 +++++++- db/schema.rb | 16 +++++--- public/stylesheets/application.css | 4 +- .../stylesheets/application.css | 13 +++++- 11 files changed, 117 insertions(+), 55 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c42944947..38ae662fc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -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) diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index de686493b..a317f82de 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -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 diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index d075f67ae..a005b299b 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -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 diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index bdb070cc2..104cd16cb 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -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 \ No newline at end of file diff --git a/app/models/tracker.rb b/app/models/tracker.rb index d487de67e..6a0069975 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -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 diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index 92e20f9e4..004fb38ac 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -46,7 +46,7 @@ - <%= content_tag('span', "#{changesets_num(@project)}", :class => "info") %> + <%= content_tag('span', "#{get_project_score(@project).nil? ? 0:get_project_score(@project).changeset_num}", :class => "info") %> <%= content_tag('span', l(:label_commit_on)) %> @@ -87,7 +87,7 @@ <% end %> -
+
<% if(@project.project_type==1)%> diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb index 38b8ac85c..01889f1f3 100644 --- a/app/views/tags/_tag_name.html.erb +++ b/app/views/tags/_tag_name.html.erb @@ -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 %> diff --git a/app/views/trackers/_form.html.erb b/app/views/trackers/_form.html.erb index 9039bba68..5acd0da1b 100644 --- a/app/views/trackers/_form.html.erb +++ b/app/views/trackers/_form.html.erb @@ -1,6 +1,6 @@ <%= error_messages_for 'tracker' %> -
+

<%= f.text_field :name, :required => true %>

@@ -39,14 +39,27 @@ <%= submit_tag l(@tracker.new_record? ? :button_create : :button_save) %>
-
+
<% if @projects.any? %>
<%= l(:label_project_plural) %> +
<%= 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 %> +
<%= hidden_field_tag('tracker[project_ids][]', '', :id => nil) %> +

<%= check_all_links 'tracker_project_ids' %>

+
<% end %> +
diff --git a/db/schema.rb b/db/schema.rb index 525cfb745..db51ddd37 100644 --- a/db/schema.rb +++ b/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| diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 9d1a6bc93..1a95f0c64 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -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;} diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 9baa5526c..098e02be2 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -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;