Merge branch 'dev_zanle' into szzh

Conflicts:
	config/routes.rb
This commit is contained in:
sw 2015-01-30 09:05:47 +08:00
commit ce526fde77
48 changed files with 1307 additions and 65 deletions

3
.gitignore vendored
View File

@ -7,8 +7,11 @@
/config/configuration.yml
/files/*
/log/*
/public/tmp/*
/tmp/*
/public/cache/*
.gitignore
/config/newrelic.yml
/public/images/avatars/*
/Gemfile
/Gemfile.lock

View File

@ -0,0 +1,3 @@
#safe table
#Mon Jan 05 10:27:54 CST 2015
connections=connections.15

View File

@ -0,0 +1,4 @@
#safe table
#Mon Jan 05 10:27:54 CST 2015
defaultConnection=defaultConnection.15
sites=sites.15

View File

@ -0,0 +1,3 @@
#safe table
#Mon Jan 05 10:27:28 CST 2015
webservers=webservers.12

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<session version="1.0">&#x0A;<refactoring comment="Delete resource &apos;trustie2&apos;" deleteContents="false" description="Delete resource &apos;trustie2&apos;" element1="/trustie2" flags="7" id="org.eclipse.ltk.core.refactoring.delete.resources" resources="1" stamp="1420424676858"/>&#x0A;<refactoring comment="Delete resource &apos;trustie2&apos;" deleteContents="false" description="Delete resource &apos;trustie2&apos;" element1="/trustie2" flags="7" id="org.eclipse.ltk.core.refactoring.delete.resources" resources="1" stamp="1420424775104"/>
</session>

View File

@ -0,0 +1,2 @@
1420424676858 Delete resource 'trustie2'
1420424775104 Delete resource 'trustie2'

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="RefactoringWizard.preview">
<item value="400" key="height"/>
<item value="600" key="width"/>
</section>
</section>

View File

@ -11,4 +11,16 @@
<item value="org.eclipse.rcp:3.7.2.v20120120-1424-9DB5FmnFq5JCf1UA38R-kz0S0272"/>
<item value="org.radrails.rails:3.4.2.201308081726-7n-7Z7oKfjkqlemv"/>
</list>
<section name="ChooseWorkspaceDialogSettings">
<item value="316" key="DIALOG_Y_ORIGIN"/>
<item value="656" key="DIALOG_X_ORIGIN"/>
</section>
<section name="WORKBENCH_SETTINGS">
<list key="ENABLED_TRANSFERS">
</list>
</section>
<section name="ExternalProjectImportWizard">
<item value="false" key="WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"/>
<item value="false" key="WizardProjectsImportPage.STORE_COPY_PROJECT_ID"/>
</section>
</section>

View File

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="NewWizardAction">
</section>
<section name="ImportExportAction">
<item value="com.aptana.projects.internal.wizards.PromoteToProjectWizard" key="ImportExportPage.STORE_SELECTED_IMPORT_WIZARD_ID"/>
<item value="org.eclipse.ui.wizards.import.ExternalProject" key="ImportExportPage.STORE_SELECTED_IMPORT_WIZARD_ID"/>
<list key="ImportExportPage.STORE_EXPANDED_IMPORT_CATEGORIES">
<item value="org.eclipse.ui.Basic"/>
<item value="com.aptana.git.ui.clone.category"/>

View File

@ -20,7 +20,8 @@ gem "builder", "3.0.0"
gem 'acts-as-taggable-on', '2.4.1'
gem 'spreadsheet'
gem 'ruby-ole'
#gem 'email_verifier'
gem 'email_verifier'
gem 'newrelic_rpm'
group :development do
gem 'grape-swagger'

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the system_log controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -31,16 +31,14 @@ class ProjectsController < ApplicationController
menu_item :feedback, :only => :feedback
menu_item l(:label_course_file), :only => :index
menu_item l(:label_course_news), :only => :index
# edit
before_filter :authorize1, :only => [:show]
#
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project]
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches]
# before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file,
# :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share,
# :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index]
#此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member
before_filter :authorize, :only => [:settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
before_filter :file, :statistics, :watcherlist
@ -118,8 +116,8 @@ class ProjectsController < ApplicationController
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").joins("LEFT JOIN #{ProjectScore.table_name} ON #{Project.table_name}.id = #{ProjectScore.table_name}.project_id").
where("#{Project.table_name}.project_type = ? ", Project::ProjectType_project)
@poll_questions_count = @projects_all.count
@poll_questions_pages = Paginator.new @project_count, per_page_option, params['page']
@project_count = @projects_all.count
@project_pages = Paginator.new @project_count, per_page_option, params['page']
#gcm activity count
@ -558,11 +556,6 @@ class ProjectsController < ApplicationController
# Show @project
def show
if(@project && !@project.is_public && !User.current.member_of?(@project))
render_403
return
end
@project_type = params[:project_type]
# try to redirect to the requested menu item
@ -594,7 +587,7 @@ class ProjectsController < ApplicationController
end
has = {
"show_issues" => true,
"show_issues" => true ,
"show_files" => true,
"show_documents" => true,
"show_messages" => true,
@ -604,8 +597,8 @@ class ProjectsController < ApplicationController
"show_wiki_edits"=>true,
"show_journals_for_messages" => true
}
@date_to ||= Date.today + 1
@date_from = @date_to - @days#-1.years #modified by lizanle 去掉這個1年的時間跨度
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
# 决定显示所用用户或单个用户活动
@ -619,9 +612,9 @@ class ProjectsController < ApplicationController
# modify by nwb
# 添加私密性判断
if User.current.member_of?(@project)|| User.current.admin?
events = @activity.events(@days)
events = @activity.events(@date_from, @date_to)
else
events = @activity.events(@days,nil, :is_public => 1)
events = @activity.events(@date_from, @date_to, :is_public => 1)
end
@offset, @limit = api_offset_and_limit({:limit => 10})
@ -917,14 +910,6 @@ class ProjectsController < ApplicationController
end
end
end
#加入私有项目
def join_project
respond_to do |format|
format.js
end
end
private
def memberAccess

View File

@ -0,0 +1,59 @@
# Time 2015-01-26 17:12:23
# Author lizanle
# Description 显示和清理系统日志
class SystemLogController < ApplicationController
before_filter :require_admin
# 默认每页显示20条记录
PER_PAGE = 20
layout "base"
include SystemLogHelper
# Time 2015-01-26 17:12:46
# Author lizanle
# Description 查看所有日志
def index
@logs = SystemLog.logo_data(params[:page]||1, params[:per]||PER_PAGE, params[:search], params[:day])
end
# Time 2015-01-26 14:42:38
# Author lizanle
# Description 清除日志
def clear
SystemLog.clear params[:day]
redirect_to :action => :index
end
# Time 2015-01-26 17:24:25
# Author lizanle
# Description 访问分析
def access_analysis
#解析日志,然后逆序
@log_result = SystemLog.analysis(params[:day]).reverse[1...-1]
@access_module = Hash.new
#日誌可能為空
if @log_result && !@log_result.empty?
#将数组中的模块访问统计出来放到hash中 每条记录的第四个值是Controller#action的形式
@log_result.collect! { |r| @access_module[r[3]].nil? ?
@access_module[r[3]] = 1 : @access_module[r[3]] +=1 }
# 去掉key可能为空记录 排序,然后取逆序
@access_module = @access_module.delete_if { |k, v| k.nil? }.sort_by { |key, val| val }.reverse
else
@access_module
end
end
# Time 2015-01-26 17:24:36
# Author lizanle
# Description 耗时分析
def time_analysis
#解析日志
@log_result = SystemLog.analysis(params[:day]).reverse[1...-1]
if @log_result && !@log_result.empty?
#分页
@log_result = Kaminari.paginate_array(@log_result).page(params[:page]||1).per(params[:per]||PER_PAGE)
else
@log_result = []
end
end
end

View File

@ -0,0 +1,16 @@
module ExpireHelper
#index.html 中 “projects”塊 緩存過期
def expire_project_cache
ActionController::Base.new.expire_fragment('projects')
end
#index.html 中 “activities”塊 緩存過期
def expire_activitie_cache
ActionController::Base.new.expire_fragment('activities')
end
#welcome/index.html 中 “forums”塊 緩存過期
def expire_forum_cache
ActionController::Base.new.expire_fragment('forums')
end
end

View File

@ -0,0 +1,180 @@
# Time 2015-01-26 17:30:16
# Author lizanle
# Description 日志帮助类
module SystemLogHelper
class SystemLog
class << self
# Time 2015-01-26 17:29:17
# Author lizanle
# Description 分页(支持多关键字查询)
def logo_data(page, per, search, day)
logs = find_all_logs day
if logs.empty? #如果返回的是空數組,就說明日誌文件不存在
return logs
end
# 根据search参数来决定是否需要查询
keywords = search
if keywords && !keywords.strip.blank?
# 把keywords转化成正则表达式数组
keywords = keywords.strip.split(/\s+/).collect! { |w| Regexp.new(w, 'i') }
# 一条记录应该匹配每个关键字 log =~ r 是对log记录进行判断是否符合r的正则表达式
logs = logs.find_all do |log|
keywords.all? { |r| log =~ r }
end
#用Kaminari分页
logs = Kaminari.paginate_array(logs).page(page).per(per).collect! { |log| parse(log) }
#将分页后的记录的搜索结果添加样式,样式中的\0是给给r占位置的。
logs.collect! do |log|
keywords.each { |r| log.gsub!(r, '<span class="search_results">\0</span>') }
log
end
else
logs = Kaminari.paginate_array(logs).page(page).per(per).collect! { |log| parse(log) }
end
logs
end
# Time 2015-01-26 17:28:57
# Author lizanle
# Description 清除日誌
def clear day
if File::exists?(logfile_path day)
File.open(logfile_path(day), 'w') do |f|
f.print ''
end
else
end
end
# Time 2015-01-26 17:28:49
# Author lizanle
# Description 讀取日誌
private
def find_all_logs day
if File::exists?(logfile_path day)
File.open(logfile_path day) do |f|
#打开文件并按照正则表达式切分逆序最新一个记录可以扔掉因为最新的记录永远都是访问System_log)
f.read.split("Processing").reverse[1..-1]
end
else
[]
end
end
# Time 2015-01-26 17:28:34
# Author lizanle
# Description 日志文件的路径一般在Rails.root/log下根据环境配置
# 依次记录到product.log development.log test.log中
def logfile_path day
#将日期处理成2015-01-01的形式
unless day.nil?
dayArr = day.split('-')
if dayArr[1].length == 1
dayArr[1] = "0" + dayArr[1]
end
if dayArr[2].length == 1
dayArr[2] = "0" + dayArr[2]
end
day = dayArr.join('-')
end
#如果不是當天,則需要加後綴
if !day.nil? && !day.strip.blank? && day != Time.now.strftime("%Y-%m-%d")
File.join(Rails.root, "log", "#{Rails.env}.log.#{day.gsub('-', '')}")
else
File.join(Rails.root, "log", "#{Rails.env}.log")
end
end
# Time 2015-01-26 17:28:22
# Author lizanle
# Description 替換換行符
def parse(log)
ERB::Util.html_escape(log.gsub(/\e\[[\d;m]+/, '')).gsub("\n", "<br/>")
end
# Time 2015-01-26 17:28:07
# Author lizanle
# Description 定义响应正则表达式 2015-01-20 11:31:13 INFO -- Completed 200 OK in 125ms (Views: 81.0ms | ActiveRecord: 2.0ms)
def response_regex
'Completed \d+ \w+ in (\d+)ms \(Views: (\d+\.\d+)?ms \| ActiveRecord: (\d+\.\d+)?ms\)'
end
# Time 2015-01-26 17:27:51
# Author lizanle
# Description 将一条记录中的地址主机等都分析出来
def get_status(paragraph)
request_regex = 'Started GET \"(\/.*)\" for ([\d]+\.[\d]+\.[\d]+\.[\d]+) at [\d]*-([\d]*-[\d]* [\d]*:[\d]*:[\d]*)'
controller_regex = 'Processing by ([\w]+#[\w]+)'
page_time_regex = 'Views: \d+(\.\d+)?ms'
activeRecord_time_regex = 'ActiveRecord: \d+(\.\d+)?ms'
#解析请求中的正则,主机,时间
if paragraph.match(request_regex) != nil
request_url = paragraph.match(request_regex)[1] #正则表达式中的括号能够截取成数组
request_host = paragraph.match(request_regex)[2]
request_at = paragraph.match(request_regex)[3]
end
#解析控制器
if paragraph.match(controller_regex) != nil
controller_name = paragraph.match(controller_regex)[1]
end
#解析响应时间以及计算百分比
if paragraph.match(response_regex) != nil
#print(paragraph.match(response_regex))
total_time = paragraph.match(response_regex)[1]
page_time = paragraph.match(response_regex)[2]
activeRecord_time = paragraph.match(response_regex)[3]
page_time_percent = page_time.to_f/(total_time.to_f)
activeRecord_time_percent = activeRecord_time.to_f/(total_time.to_f)
else
end
#将解析结果当做一条记录数组返回
request_status = [request_url, request_host, request_at,
controller_name, total_time, page_time, page_time_percent, activeRecord_time, activeRecord_time_percent]
request_status
end
# Time 2015-01-26 16:41:51
# Author lizanle
# Description 分析日志
public
def analysis day
csv = Array.new
#如果文件不存在,则直接返回空数组
if File::exists?(logfile_path day)
File.open(logfile_path(day), "r:utf-8") do |file|
paragraph = ""
begin_flag = false
# 对每一行进行判断
file.each do |line|
# 以"Started GET "开头为一个paragraph
#print(line.match('[\d]*-([\d]*-[\d]* [\d]*:[\d]*:[\d]*) INFO -- Started GET ') == nil)
if (line.match('[\d]*-([\d]*-[\d]* [\d]*:[\d]*:[\d]*) \w+ -- Started GET ') != nil)
if !begin_flag
begin_flag = true
paragraph.concat(line)
else
# 另一个paragraph的开头
if (paragraph.match(response_regex) != nil)
csv << get_status(paragraph)
end
begin_flag = true
paragraph = line
end
else
if begin_flag
paragraph.concat(line)
else
end
end
end
end
end
csv
end
end
end
end

View File

@ -17,6 +17,7 @@ class Bid < ActiveRecord::Base
HomeworkProject = 2
attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password
include Redmine::SafeAttributes
include ExpireHelper
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
belongs_to :course
@ -32,7 +33,11 @@ class Bid < ActiveRecord::Base
has_many :join_in_contests, :dependent => :destroy
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
# has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}"
after_create :expire_activitie_cache
after_update :expire_activitie_cache
before_destroy :expire_activitie_cache
acts_as_attachable
@ -149,4 +154,6 @@ class Bid < ActiveRecord::Base
end
end
end
end

View File

@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class Changeset < ActiveRecord::Base
include ExpireHelper
belongs_to :repository
belongs_to :user
include UserScoreHelper
@ -64,8 +65,9 @@ class Changeset < ActiveRecord::Base
includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args))
}
after_create :scan_for_issues,:refresh_changests#:be_user_score # user_score
after_update :be_user_score
after_create :scan_for_issues,:refresh_changests,:expire_activitie_cache#:be_user_score # user_score
after_update :be_user_score,:expire_activitie_cache
before_destroy :expire_activitie_cache
after_destroy :down_user_score
before_create :before_create_cs

View File

@ -1,4 +1,10 @@
class ContestNotification < ActiveRecord::Base
include ExpireHelper
attr_accessible :content, :title
validates :title, length: {maximum: 30}
after_create :expire_forum_cache
after_update :expire_forum_cache
before_destroy :expire_forum_cache
end

View File

@ -17,18 +17,22 @@
class Document < ActiveRecord::Base
include Redmine::SafeAttributes
include ExpireHelper
belongs_to :project
belongs_to :user
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
include UserScoreHelper
after_save :be_user_score # user_score
after_destroy :down_user_score
after_create :expire_activitie_cache
after_update :expire_activitie_cache
before_destroy :expire_activitie_cache
acts_as_attachable :delete_permission => :delete_documents
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
#:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
:author => Proc.new {|o| User.find(o.user_id)},
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
acts_as_activity_provider :find_options => {:include => :project},
:is_public => 'documents.is_public'
@ -76,4 +80,6 @@ class Document < ActiveRecord::Base
update_document(self.user,1)
update_document(self.user,2,self.project)
end
end

View File

@ -1,8 +1,13 @@
class Forum < ActiveRecord::Base
include Redmine::SafeAttributes
include ExpireHelper
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC", :dependent => :destroy
has_many :memos, :dependent => :destroy, conditions: "parent_id IS NULL"
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
after_create :expire_forum_cache
after_update :expire_forum_cache
before_destroy :expire_forum_cache
safe_attributes 'name',
'description',
'topic_count',
@ -45,5 +50,7 @@ class Forum < ActiveRecord::Base
" memo_count = (SELECT COUNT(*) FROM #{Memo.table_name} WHERE forum_id=#{forum_id} AND parent_id IS NOT NULL)," +
" last_memo_id = (SELECT MAX(id) FROM #{Memo.table_name} WHERE forum_id=#{forum_id})",
["id = ?", forum_id])
end
end
end

View File

@ -19,7 +19,7 @@ class Issue < ActiveRecord::Base
include Redmine::SafeAttributes
include Redmine::Utils::DateCalculation
include UserScoreHelper
include ExpireHelper
belongs_to :project
belongs_to :tracker
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
@ -80,6 +80,9 @@ class Issue < ActiveRecord::Base
after_create :act_as_activity,:be_user_score_new_issue
after_update :be_user_score
after_destroy :down_user_score
after_create :expire_activitie_cache
after_update :expire_activitie_cache
before_destroy :expire_activitie_cache
# after_create :be_user_score
# end
@ -1553,4 +1556,5 @@ class Issue < ActiveRecord::Base
end
end

View File

@ -4,6 +4,7 @@
class JournalsForMessage < ActiveRecord::Base
include Redmine::SafeAttributes
include UserScoreHelper
include ExpireHelper
safe_attributes "jour_type", # 留言所属类型
"jour_id", # 留言所属类型的id
"notes", # 留言内容
@ -54,7 +55,9 @@ class JournalsForMessage < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
validates :notes, presence: true
after_create :act_as_activity #huang
after_create :act_as_activity ,:expire_activitie_cache#huang
after_update :expire_activitie_cache
before_destroy :expire_activitie_cache
after_create :reset_counters!
after_destroy :reset_counters!
after_save :be_user_score
@ -162,4 +165,6 @@ class JournalsForMessage < ActiveRecord::Base
end
end
end
end

View File

@ -1,9 +1,13 @@
class Memo < ActiveRecord::Base
include Redmine::SafeAttributes
include UserScoreHelper
include ExpireHelper
belongs_to :forum
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
after_create :expire_cache
after_update :expire_cache
before_destroy :expire_cache
validates_presence_of :author_id, :forum_id, :subject,:content
# 若是主题帖,则内容可以是空
#validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
@ -170,5 +174,8 @@ class Memo < ActiveRecord::Base
update_memo_number(User.current,1)
update_replay_for_memo(User.current,1)
end
def expire_cache
expire_forum_cache
expire_activitie_cache
end
end

View File

@ -18,7 +18,7 @@
class Message < ActiveRecord::Base
include Redmine::SafeAttributes
include UserScoreHelper
include ExpireHelper
belongs_to :board
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
@ -59,8 +59,9 @@ class Message < ActiveRecord::Base
validates_length_of :subject, :maximum => 255
validate :cannot_reply_to_locked_topic, :on => :create
after_create :add_author_as_watcher, :reset_counters!
after_update :update_messages_board
after_create :add_author_as_watcher, :reset_counters!,:expire_activitie_cache
after_update :update_messages_board,:expire_activitie_cache
before_destroy :expire_activitie_cache
after_destroy :reset_counters!,:down_user_score
# fq
@ -195,4 +196,6 @@ class Message < ActiveRecord::Base
end
end
end
end

View File

@ -17,6 +17,7 @@
class News < ActiveRecord::Base
include Redmine::SafeAttributes
include ExpireHelper
belongs_to :project
#added by nwb
belongs_to :course
@ -47,6 +48,9 @@ class News < ActiveRecord::Base
# fq
after_create :act_as_activity
# end
after_create :expire_activitie_cache
after_update :expire_activitie_cache
before_destroy :expire_activitie_cache
scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
@ -91,4 +95,6 @@ class News < ActiveRecord::Base
def act_as_activity
self.acts << Activity.new(:user_id => self.author_id)
end
end

View File

@ -17,6 +17,7 @@
class Project < ActiveRecord::Base
include Redmine::SafeAttributes
include ExpireHelper
ProjectType_project = 0
ProjectType_course = 1
@ -125,10 +126,12 @@ class Project < ActiveRecord::Base
#此代码功能为原redmine中项目的树形结构按名称首字母排序本系统项目非树形结构且项目排序方式无按首字母排序另该代码执行会使空数据库时创建项目时出异常故注释掉
#after_save :update_position_under_parent, :if => Proc.new {|project| project.name_changed?}
#ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
# 创建project之后默认创建一个board之后的board去掉了board的概念
after_create :create_board_sync
before_destroy :delete_all_members
after_create :create_board_sync,:expire_project_cache
after_update :expire_project_cache
before_destroy :delete_all_members,:expire_project_cache
def remove_references_before_destroy
return if self.id.nil?
Watcher.delete_all ['watchable_id = ?', id]
@ -1148,7 +1151,7 @@ class Project < ActiveRecord::Base
logger.error "[Project Model] ===> Auto create board when Project saved, because #{@board.full_messages}"
end
end
end

View File

@ -0,0 +1,54 @@
<%#
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>System Log</title>
<style type="text/css">
/*body {*/
/*font-size:90%;*/
/*}*/
body {
color: #333333;
font-family: lucida grande, Lucida Sans Unicode, Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 20px;
}
.search_results {
color: red;
}
/*=======分页样式========*/
.pagination ul li a, .pagination ul li span{
background-color: #FFFFFF;
border-color: #DDDDDD;
border-image: none;
border-style: solid;
border-width: 1px 1px 1px 1px;
float: left;
line-height: 20px;
padding: 4px 12px;
text-decoration: none;
}
.pagination ul a {
color: #9B9B9B;
}
.pagination ul li a:hover, .pagination ul li a:focus, .pagination ul .active a, .pagination ul .active span{
background-color: #ffc02f;
border: 1px solid #ffc02f;
}
.pagination ul li{
float: left;
margin-right: 3px;
list-style: none outside none;
}
</style>
</head>
<body onload="document.getElementById('search').focus();">
<%= yield %>
</body>
</html>

View File

@ -0,0 +1,36 @@
<% @nav_dispaly_home_path_label = 1
@nav_dispaly_main_course_label = 1
@nav_dispaly_main_project_label = 1
@nav_dispaly_main_contest_label = 1 %>
<% @nav_dispaly_forum_label = 1%>
<div id='tool'>
<p>
<form action="/system_log/access_analysis" style="float:right" >
<input name="day" type="text" size="36" value="<%= params[:day].nil? ? Time.now.strftime("%Y-%m-%d") : params[:day] %>" maxlength="100" readonly="true" onclick="HS_setDate(this)"/>
<input type="submit" value="<%=l(:label_search_member)%>" size="30" id="search"/>
</form>
</p>
<div id='tool-bar'>
<%=link_to l(:label_log_detail), system_log_path %> |
<%=link_to l(:label_log_delete_log), system_log_clear_path, {:confirm => l(:label_log_delete_confirm),:day=>params[:day].nil? ? Time.now.strftime("%Y-%m-%d") : params[:day]}%> |
<%=link_to l(:label_log_access_analysis), system_log_access_analysis_path %> |
<%=link_to l(:label_log_time_analysis), system_log_time_analysis_path %> |
<%=link_to_function l(:label_log_refresh), 'redo()' %>
</div>
</div>
<div>&nbsp;&nbsp;</div>
<table border="2" width="100%">
<caption font-size="30px"><%= l(:label_log_access_analysis)%></caption>
<tr><td><%= l(:label_log_access_controller_action)%></td>
<td><%= l(:label_log_access_count)%></td></tr>
<% unless @access_module.nil? %>
<% @access_module.each do |k, v| %>
<% unless k.blank? %>
<tr><td><%= raw k %></td>
<td><%= raw v %></td></tr>
<% end %>
<%end %>
<%end %>
</table>

View File

@ -0,0 +1,45 @@
<% @nav_dispaly_home_path_label = 1
@nav_dispaly_main_course_label = 1
@nav_dispaly_main_project_label = 1
@nav_dispaly_main_contest_label = 1 %>
<% @nav_dispaly_forum_label = 1%>
<div id='tool'>
<div id='tool-bar' style="float: left">
<%=link_to l(:label_log_detail), system_log_path %> |
<%=link_to l(:label_log_delete_log), system_log_clear_path, {:confirm => l(:label_log_delete_confirm),:day=>params[:day].nil? ? Time.now.strftime("%Y-%m-%d") : params[:day]}%> |
<%=link_to l(:label_log_access_analysis), system_log_access_analysis_path %> |
<%=link_to l(:label_log_time_analysis), system_log_time_analysis_path %> |
<%=link_to_function l(:label_log_refresh), 'redo()' %>
</div>
<div id="search-bar" style="float: right">
<form action="/system_log" style="float:right" >
<p>
<%= l(:label_log_key) %><input type="text" name="search" size="36" value="<%= params[:search] %>" maxlength="100" style="margin-right: 12px" />
</p>
<p>
&nbsp;&nbsp;&nbsp;<%=l(:label_log_time)%><input name="day" type="text" id="day" size="36" value="<%= params[:day].nil? ? Time.now.strftime("%Y-%m-%d") : params[:day] %>" maxlength="100" readonly="true" onclick="HS_setDate(this)"/>
<input type="submit" value="<%=l(:label_search_member)%>" size="30" id="search"/>
</p>
</form>
</div>
</div>
<div style="clear: both">&nbsp;&nbsp;</div>
<div>
<%= paginate @logs unless @logs.empty? %><br/>
<% unless @logs.empty? %>
<table border="2" >
<caption font-size="30px"><%=l(:label_log_detail)%></caption>
<% @logs.each do |log| %>
<% unless log.blank? %>
<tr><td><%= raw log %></td></tr>
<% end %>
<%end %>
</table>
<%end %>
<%= paginate @logs unless @logs.empty? %>
</div>

View File

@ -0,0 +1,51 @@
<% @nav_dispaly_home_path_label = 1
@nav_dispaly_main_course_label = 1
@nav_dispaly_main_project_label = 1
@nav_dispaly_main_contest_label = 1 %>
<% @nav_dispaly_forum_label = 1%>
<div id='tool'>
<p>
<form action="/system_log/time_analysis" style="float:right" >
<input name="day" type="text" size="36" value="<%= params[:day].nil? ? Time.now.strftime("%Y-%m-%d") : params[:day] %>" maxlength="100" readonly="true" onclick="HS_setDate(this)"/>
<input type="submit" value="<%=l(:label_search_member)%>" size="30" id="search"/>
</form>
</p>
<div id='tool-bar'>
<%=link_to l(:label_log_detail), system_log_path %> |
<%=link_to l(:label_log_delete_log), system_log_clear_path, {:confirm => l(:label_log_delete_confirm),:day=>params[:day].nil? ? Time.now.strftime("%Y-%m-%d") : params[:day]}%> |
<%=link_to l(:label_log_access_analysis), system_log_access_analysis_path %> |
<%=link_to l(:label_log_time_analysis), system_log_time_analysis_path %> |
<%=link_to_function l(:label_log_refresh), 'redo()' %>
</div>
</div>
<div>&nbsp;&nbsp;</div>
<%= paginate @log_result unless @log_result.empty? %><br/>
<table border="2" >
<caption font-size="30px"><%= l(:label_log_time_analysis) %></caption>
<tr><td width="10%"><%= l(:label_log_url) %></td>
<td width="10%"><%= l(:label_log_ip) %></td>
<td width="10%"><%= l(:label_log_access_time) %></td>
<td width="10%"><%= l(:label_log_access_controller_action) %></td>
<td width="10%"><%= l(:label_log_response_time) %></td>
<td width="10%"><%= l(:label_log_views_time) %></td>
<td width="10%"><%= l(:label_log_views_time_percent) %></td>
<td width="10%"><%= l(:label_log_active_record_time) %></td>
<td width="10%"><%= l(:label_log_active_record_time_percent) %></td></tr>
<% unless @log_result.nil? %>
<% @log_result.each do |r| %>
<% unless r.blank? %>
<!-- #如果请求地址不为空且长度大于50那么我们就截取长度20 %-->
<tr><td width="10%"><%= raw r[0].length>50?r[0].truncate(20) : r[0] unless r[0].nil? %></td>
<td width="10%"><%= raw r[1] %></td>
<td width="10%"><%= raw r[2] %></td>
<td width="10%"><%= raw r[3] %></td>
<td width="10%"><%= raw r[4] %></td>
<td width="10%"><%= raw r[5] %></td>
<td width="10%"><%= raw r[6] %></td>
<td width="10%"><%= raw r[7] %></td>
<td width="10%"><%= raw r[8] %></td></tr>
<% end %>
<%end %>
<%end %>
</table>
<%= paginate @log_result unless @log_result.empty? %><br/>

View File

@ -73,8 +73,10 @@
</span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% cache("projects") do %>
<% @projects.map do |project| %>
<li style="overflow:hidden;word-break:break-all;height:100%;word-wrap: break-word;" class='<%= cycle("odd", "even") %>'>
<% cache project do %>
<li style="overflow:auto;word-break:break-all;height:100%;word-wrap: break-word;" class='<%= cycle("odd", "even") %>'>
<div style="float: left;">
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
</div>
@ -101,8 +103,9 @@
:id => "tooltip-#{project.id}" %>
</div>
</li>
<!--<%#end %> -->
<% end %>
<% end; reset_cycle %>
<% end %>
</ul>
</div>
</div>
@ -115,8 +118,10 @@
</strong>
</h3>
<div class="user-message-box-list" style="margin-top: 10px;">
<% cache("activities") do %>
<%activities = find_all_activities%>
<% activities.each do |event| %>
<% cache event do %>
<li style="display: block;height:60px; padding-bottom: 4px;">
<div class="inner-right" style="float: left; height: 100%; ">
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
@ -130,7 +135,7 @@
<p style="margin-top: 4px;">
<span style="color: rgb(172, 174, 177)">
<%= l(:field_updated_on) %>
<%= time_tag_welcome event.event_datetime %>前
<%= format_time event.event_datetime %>
</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style="float: right; color: rgb(172, 174, 177);">
@ -139,7 +144,9 @@
</p>
</div>
</li>
<% end %>
<% end %>
<% end %>
</div>
</ul>
</div>
@ -160,9 +167,10 @@
</span>
</div>
<div class="welcome-box-list-new memo_activity">
<% cache("forums") do %>
<% topics = find_new_forum_topics(6) %>
<% topics.includes(:forum, :last_reply, :author).each do |topic|%>
<!--<%# cache cache_key_for_topic(topic) do %> -->
<% cache topic do %>
<li class="message-brief-intro">
<div class='memo_title text_nowrap'>
<%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %>
@ -170,7 +178,9 @@
</div>
<div class='memo_attr'>
<span class='memo_timestamp'>
<%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %>
<%#= "#{l(:field_updated_on, value: format_time(topic_last_time topic))}" %>
<%= l(:field_updated_on) %>
<%= format_time topic_last_time topic %>
</span>
<span class="memo_author">
<%= l(:label_question_sponsor)%>
@ -188,8 +198,9 @@
</span>
</div>
</li>
<!--<%#end %> --> <!-- cache -->
<% end %>
<%end %>
<% end %>
<% end %>
</div>
</ul>
</div>

View File

@ -7,11 +7,11 @@ RedmineApp::Application.configure do
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
config.logger = Logger.new('log/development.log', 'daily') # daily, weekly or monthly
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :file_store, "#{Rails.root }/public/tmp/"
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true

View File

@ -17,8 +17,9 @@ RedmineApp::Application.configure do
# config.logger.level = Logger::INFO
# Full error reports are disabled and caching is turned on
config.logger = Logger.new('log/production.log', 'daily',1048576) # daily, weekly or monthly
config.action_controller.perform_caching = true
config.cache_store = :file_store, "#{Rails.root }/public/tmp/"
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"

View File

@ -0,0 +1,229 @@
# logger.rb - simple logging utility
# Copyright (C) 2000-2003, 2005, 2008, 2011 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
#
# Documentation:: NAKAMURA, Hiroshi and Gavin Sinclair
# License::
# You can redistribute it and/or modify it under the same terms of Ruby's
# license; either the dual license version in 2003, or any later version.
# Revision:: $Id: logger.rb 31641 2011-05-19 00:07:25Z nobu $
#
# A simple system for logging messages. See Logger for more documentation.
require 'monitor'
require 'fileutils'
# == Description
#
# The Logger class provides a simple but sophisticated logging utility that
# you can use to output messages.
#
# The messages have associated levels, such as +INFO+ or +ERROR+ that indicate
# their importance. You can then give the Logger a level, and only messages
# at that level of higher will be printed.
#
# The levels are:
#
# +FATAL+:: an unhandleable error that results in a program crash
# +ERROR+:: a handleable error condition
# +WARN+:: a warning
# +INFO+:: generic (useful) information about system operation
# +DEBUG+:: low-level information for developers
#
# For instance, in a production system, you may have your Logger set to
# +INFO+ or even +WARN+
# When you are developing the system, however, you probably
# want to know about the program's internal state, and would set the Logger to
# +DEBUG+.
#
# *Note*: Logger does not escape or sanitize any messages passed to it.
# Developers should be aware of when potentially malicious data (user-input)
# is passed to Logger, and manually escape the untrusted data:
#
# logger.info("User-input: #{input.dump}")
# logger.info("User-input: %p" % input)
#
# You can use #formatter= for escaping all data.
#
# original_formatter = Logger::Formatter.new
# logger.formatter = proc { |severity, datetime, progname, msg|
# original_formatter.call(severity, datetime, progname, msg.dump)
# }
# logger.info(input)
#
# === Example
#
# This creates a logger to the standard output stream, with a level of +WARN+
#
# log = Logger.new(STDOUT)
# log.level = Logger::WARN
#
# log.debug("Created logger")
# log.info("Program started")
# log.warn("Nothing to do!")
#
# begin
# File.each_line(path) do |line|
# unless line =~ /^(\w+) = (.*)$/
# log.error("Line in wrong format: #{line}")
# end
# end
# rescue => err
# log.fatal("Caught exception; exiting")
# log.fatal(err)
# end
#
# Because the Logger's level is set to +WARN+, only the warning, error, and
# fatal messages are recorded. The debug and info messages are silently
# discarded.
#
# === Features
#
# There are several interesting features that Logger provides, like
# auto-rolling of log files, setting the format of log messages, and
# specifying a program name in conjunction with the message. The next section
# shows you how to achieve these things.
#
#
# == HOWTOs
#
# === How to create a logger
#
# The options below give you various choices, in more or less increasing
# complexity.
#
# 1. Create a logger which logs messages to STDERR/STDOUT.
#
# logger = Logger.new(STDERR)
# logger = Logger.new(STDOUT)
#
# 2. Create a logger for the file which has the specified name.
#
# logger = Logger.new('logfile.log')
#
# 3. Create a logger for the specified file.
#
# file = File.open('foo.log', File::WRONLY | File::APPEND)
# # To create new (and to remove old) logfile, add File::CREAT like;
# # file = open('foo.log', File::WRONLY | File::APPEND | File::CREAT)
# logger = Logger.new(file)
#
# 4. Create a logger which ages logfile once it reaches a certain size. Leave
# 10 "old log files" and each file is about 1,024,000 bytes.
#
# logger = Logger.new('foo.log', 10, 1024000)
#
# 5. Create a logger which ages logfile daily/weekly/monthly.
#
# logger = Logger.new('foo.log', 'daily')
# logger = Logger.new('foo.log', 'weekly')
# logger = Logger.new('foo.log', 'monthly')
#
# === How to log a message
#
# Notice the different methods (+fatal+, +error+, +info+) being used to log
# messages of various levels? Other methods in this family are +warn+ and
# +debug+. +add+ is used below to log a message of an arbitrary (perhaps
# dynamic) level.
#
# 1. Message in block.
#
# logger.fatal { "Argument 'foo' not given." }
#
# 2. Message as a string.
#
# logger.error "Argument #{ @foo } mismatch."
#
# 3. With progname.
#
# logger.info('initialize') { "Initializing..." }
#
# 4. With severity.
#
# logger.add(Logger::FATAL) { 'Fatal error!' }
#
# The block form allows you to create potentially complex log messages,
# but to delay their evaluation until and unless the message is
# logged. For example, if we have the following:
#
# logger.debug { "This is a " + potentially + " expensive operation" }
#
# If the logger's level is +INFO+ or higher, no debug messages will be logged,
# and the entire block will not even be evaluated. Compare to this:
#
# logger.debug("This is a " + potentially + " expensive operation")
#
# Here, the string concatenation is done every time, even if the log
# level is not set to show the debug message.
#
# === How to close a logger
#
# logger.close
#
# === Setting severity threshold
#
# 1. Original interface.
#
# logger.sev_threshold = Logger::WARN
#
# 2. Log4r (somewhat) compatible interface.
#
# logger.level = Logger::INFO
#
# DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
#
#
# == Format
#
# Log messages are rendered in the output stream in a certain format by
# default. The default format and a sample are shown below:
#
# Log format:
# SeverityID, [Date Time mSec #pid] SeverityLabel -- ProgName: message
#
# Log sample:
# I, [Wed Mar 03 02:34:24 JST 1999 895701 #19074] INFO -- Main: info.
#
# You may change the date and time format via #datetime_format=
#
# logger.datetime_format = "%Y-%m-%d %H:%M:%S"
# # e.g. "2004-01-03 00:54:26"
#
# Or, you may change the overall format with #formatter= method.
#
# logger.formatter = proc do |severity, datetime, progname, msg|
# "#{datetime}: #{msg}\n"
# end
# # e.g. "Thu Sep 22 08:51:08 GMT+9:00 2005: hello world"
#
class Logger
#具体内容请看https://bugs.ruby-lang.org/issues/7303
# Device used for logging messages.
class LogDevice
def shift_log_period(period_end)
postfix = period_end.strftime("%Y%m%d") # YYYYMMDD
age_file = "#{@filename}.#{postfix}"
if FileTest.exist?(age_file)
# try to avoid filename crash caused by Timestamp change.
idx = 0
# .99 can be overridden; avoid too much file search with 'loop do'
while idx < 100
idx += 1
age_file = "#{@filename}.#{postfix}.#{idx}"
break unless FileTest.exist?(age_file)
end
end
# @dev.close rescue nil
# File.rename("#{@filename}", age_file)
# @dev = create_logfile(@filename)
#覆盖原来lib库的方法将上边三行删除增加下边两行
FileUtils.cp(@filename, age_file)
reset_logfile(@dev) # see below for this new method return true
return true
end
#打开原来lib库新增一个方法
def reset_logfile(logdev)
logdev.truncate( 0 )
logdev.sync = true
add_log_header(logdev)
end
end
end

View File

@ -2310,6 +2310,31 @@ zh:
label_poll_answer_valid_result: 以上为有效问答题答案!
label_answer_total: 总计:
label_join_project: 加入项目
label_technical_support: 技术支持:
label_feedback: 意见反馈
label_log_detail: "日志详情"
label_log_delete_log: "删除日志"
label_log_access_analysis: "访问统计"
label_log_time_analysis: "耗时分析"
label_log_refresh: "刷新"
label_log_key: "关键字:"
label_log_time: "时间:"
label_log_delete_confirm: "确认清除该天日志内容?"
label_log_access_count: "访问次数"
label_log_url: "URL路径"
label_log_ip: "访问IP"
label_log_access_time: "访问时间"
label_log_access_controller_action: "模块路径"
label_log_response_time: "响应时间"
label_log_views_time: "页面渲染时间"
label_log_views_time_percent: "页面渲染时间百分比"
label_log_active_record_time: "AR响应时间"
label_log_active_record_time_percent: "AR响应时间百分比"
views:
pagination:
first: "&laquo; 首页"
last: "末页 &raquo;"
previous: "&laquo; 上一页"
next: "下一页 &raquo;"
truncate: "..."

224
config/newrelic.yml Normal file
View File

@ -0,0 +1,224 @@
#
# This file configures the New Relic Agent. New Relic monitors Ruby, Java,
# .NET, PHP, Python and Node applications with deep visibility and low
# overhead. For more information, visit www.newrelic.com.
#
# Generated January 23, 2015
#
# This configuration file is custom generated for Trustie
# Here are the settings that are common to all environments
common: &default_settings
# ============================== LICENSE KEY ===============================
# You must specify the license key associated with your New Relic
# account. This key binds your Agent's data to your account in the
# New Relic service.
license_key: '9b481f5c9ec07de722dcaaa17b38d0d1efff32c0'
# Agent Enabled (Ruby/Rails Only)
# Use this setting to force the agent to run or not run.
# Default is 'auto' which means the agent will install and run only
# if a valid dispatcher such as Mongrel is running. This prevents
# it from running with Rake or the console. Set to false to
# completely turn the agent off regardless of the other settings.
# Valid values are true, false and auto.
#
# agent_enabled: auto
# Application Name Set this to be the name of your application as
# you'd like it show up in New Relic. The service will then auto-map
# instances of your application into an "application" on your
# dashboard page. If you want to map this instance into multiple
# apps, like "AJAX Requests" and "All UI" then specify a semicolon
# separated list of up to three distinct names, or a yaml list.
# Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
# Production, Staging, etc)
#
# Example:
#
# app_name:
# - Ajax Service
# - All Services
#
# Caution: If you change this name, a new application will appear in the New
# Relic user interface with the new name, and data will stop reporting to the
# app with the old name.
#
# See https://newrelic.com/docs/site/renaming-applications for more details
# on renaming your New Relic applications.
#
app_name: My Application
# When "true", the agent collects performance data about your
# application and reports this data to the New Relic service at
# newrelic.com. This global switch is normally overridden for each
# environment below. (formerly called 'enabled')
monitor_mode: true
# Developer mode should be off in every environment but
# development as it has very high overhead in memory.
developer_mode: false
# The newrelic agent generates its own log file to keep its logging
# information separate from that of your application. Specify its
# log level here.
log_level: info
# Optionally set the path to the log file This is expanded from the
# root directory (may be relative or absolute, e.g. 'log/' or
# '/var/log/') The agent will attempt to create this directory if it
# does not exist.
# log_file_path: 'log'
# Optionally set the name of the log file, defaults to 'newrelic_agent.log'
# log_file_name: 'newrelic_agent.log'
# The newrelic agent communicates with the service via https by default. This
# prevents eavesdropping on the performance metrics transmitted by the agent.
# The encryption required by SSL introduces a nominal amount of CPU overhead,
# which is performed asynchronously in a background thread. If you'd prefer
# to send your metrics over http uncomment the following line.
# ssl: false
#============================== Browser Monitoring ===============================
# New Relic Real User Monitoring gives you insight into the performance real users are
# experiencing with your website. This is accomplished by measuring the time it takes for
# your users' browsers to download and render your web pages by injecting a small amount
# of JavaScript code into the header and footer of each page.
browser_monitoring:
# By default the agent automatically injects the monitoring JavaScript
# into web pages. Set this attribute to false to turn off this behavior.
auto_instrument: true
# Proxy settings for connecting to the New Relic server.
#
# If a proxy is used, the host setting is required. Other settings
# are optional. Default port is 8080.
#
# proxy_host: hostname
# proxy_port: 8080
# proxy_user:
# proxy_pass:
# The agent can optionally log all data it sends to New Relic servers to a
# separate log file for human inspection and auditing purposes. To enable this
# feature, change 'enabled' below to true.
# See: https://newrelic.com/docs/ruby/audit-log
audit_log:
enabled: false
# Tells transaction tracer and error collector (when enabled)
# whether or not to capture HTTP params. When true, frameworks can
# exclude HTTP parameters from being captured.
# Rails: the RoR filter_parameter_logging excludes parameters
# Java: create a config setting called "ignored_params" and set it to
# a comma separated list of HTTP parameter names.
# ex: ignored_params: credit_card, ssn, password
capture_params: false
# Transaction tracer captures deep information about slow
# transactions and sends this to the New Relic service once a
# minute. Included in the transaction is the exact call sequence of
# the transactions including any SQL statements issued.
transaction_tracer:
# Transaction tracer is enabled by default. Set this to false to
# turn it off. This feature is only available at the Professional
# and above product levels.
enabled: true
# Threshold in seconds for when to collect a transaction
# trace. When the response time of a controller action exceeds
# this threshold, a transaction trace will be recorded and sent to
# New Relic. Valid values are any float value, or (default) "apdex_f",
# which will use the threshold for an dissatisfying Apdex
# controller action - four times the Apdex T value.
transaction_threshold: apdex_f
# When transaction tracer is on, SQL statements can optionally be
# recorded. The recorder has three modes, "off" which sends no
# SQL, "raw" which sends the SQL statement in its original form,
# and "obfuscated", which strips out numeric and string literals.
record_sql: obfuscated
# Threshold in seconds for when to collect stack trace for a SQL
# call. In other words, when SQL statements exceed this threshold,
# then capture and send to New Relic the current stack trace. This is
# helpful for pinpointing where long SQL calls originate from.
stack_trace_threshold: 0.500
# Determines whether the agent will capture query plans for slow
# SQL queries. Only supported in mysql and postgres. Should be
# set to false when using other adapters.
# explain_enabled: true
# Threshold for query execution time below which query plans will
# not be captured. Relevant only when `explain_enabled` is true.
# explain_threshold: 0.5
# Error collector captures information about uncaught exceptions and
# sends them to New Relic for viewing
error_collector:
# Error collector is enabled by default. Set this to false to turn
# it off. This feature is only available at the Professional and above
# product levels.
enabled: true
# To stop specific errors from reporting to New Relic, set this property
# to comma-separated values. Default is to ignore routing errors,
# which are how 404's get triggered.
ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
# If you're interested in capturing memcache keys as though they
# were SQL uncomment this flag. Note that this does increase
# overhead slightly on every memcached call, and can have security
# implications if your memcached keys are sensitive
# capture_memcache_keys: true
# Application Environments
# ------------------------------------------
# Environment-specific settings are in this section.
# For Rails applications, RAILS_ENV is used to determine the environment.
# For Java applications, pass -Dnewrelic.environment <environment> to set
# the environment.
# NOTE if your application has other named environments, you should
# provide newrelic configuration settings for these environments here.
development:
<<: *default_settings
# Turn on communication to New Relic service in development mode
monitor_mode: true
app_name: My Application (Development)
# Rails Only - when running in Developer Mode, the New Relic Agent will
# present performance information on the last 100 transactions you have
# executed since starting the mongrel.
# NOTE: There is substantial overhead when running in developer mode.
# Do not use for production or load testing.
developer_mode: true
test:
<<: *default_settings
# It almost never makes sense to turn on the agent when running
# unit, functional or integration tests or the like.
monitor_mode: false
# Turn on the agent in production for 24x7 monitoring. NewRelic
# testing shows an average performance impact of < 5 ms per
# transaction, you can leave this on all the time without
# incurring any user-visible performance degradation.
production:
<<: *default_settings
monitor_mode: true
# Many applications have a staging environment which behaves
# identically to production. Support for that environment is provided
# here. By default, the staging environment has the agent turned on.
staging:
<<: *default_settings
monitor_mode: true
app_name: My Application (Staging)

View File

@ -26,6 +26,8 @@
# Example: :via => :get ====> :via => :get
RedmineApp::Application.routes.draw do
#match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index'
mount Mobile::API => '/api'
@ -841,6 +843,14 @@ RedmineApp::Application.routes.draw do
match 'words/add_brief_introdution'
##added by lizanle 日志查看路由
match 'system_log/index'
match 'system_log/access_analysis'
match 'system_log/time_analysis'
match "/system_log" ,:to => 'system_log#index'
match 'system_log/clear'
##ended by lizanle
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
file = File.join(plugin_dir, "config/routes.rb")

View File

@ -49,8 +49,11 @@ module Redmine
end
module ClassMethods
# Time 2015-01-27 16:30:47
# Author lizanle
# Description 用原来的写法from,to更加容易懂
# Returns events of type event_type visible by user that occured between from and to
def find_events(event_type, user, days, created_time, options)
def find_events(event_type, user, from, to, options)
provider_options = activity_provider_options[event_type]
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
@ -91,17 +94,18 @@ module Redmine
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
scope = scope.scoped(:conditions => Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
end
unless scope.all(provider_options[:find_options].dup).first.nil?
# Time 2015-01-27 15:18:33
# Author lizanle
# Description 删除 unless scope.all因为这个执行查询并且没有加入时间限制与下边 scope.all(provider_options[:find_options].dup)重复
if options[:course]
if provider_options[:timestamp].include? "updated_on"
to = scope.scoped(:order => "#{provider_options[:timestamp]} desc").all(provider_options[:find_options].dup).first.updated_on
else
to = scope.scoped(:order => "#{provider_options[:timestamp]} desc").all(provider_options[:find_options].dup).first.created_on
end
if options[:course]
from = (to - days.days) > created_time ? (to - days.days) : created_time.to_date
else
from = to - days.days - 1.years
end
else
#from = to - Setting.activity_days_default.to_i
end
if from && to

View File

@ -43,6 +43,7 @@ module Redmine
base.extend ClassMethods
end
%w(datetime title description author type).each do |attr|
src = <<-END_SRC
def event_#{attr}

View File

@ -77,9 +77,12 @@ module Redmine
@scope = Redmine::Activity.default_event_types
end
# Time 2015-01-27 16:31:58
# Author lizanle
# Description 用from to 更加浅显易懂
# Returns an array of events for the given date range
# sorted in reverse chronological order
def events(days = nil, created_time = nil, options={})
def events(from = nil, to = nil, options={})
e = []
@options[:limit] = options[:limit]
# modify by nwb
@ -87,7 +90,7 @@ module Redmine
@scope.each do |event_type|
constantized_providers(event_type).each do |provider|
e += provider.find_events(event_type, @user, days, created_time, @options)
e += provider.find_events(event_type, @user, from, to, @options)
end
end

View File

@ -685,3 +685,165 @@ function PrecentChange(obj){
$("select[id='issue_status_id']").find("option[value='2']").attr("selected","selected");
}
}
//added by lizanle 日期選擇js
function HS_DateAdd(interval,number,date){
number = parseInt(number);
if (typeof(date)=="string"){var date = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2])}
if (typeof(date)=="object"){var date = date}
switch(interval){
case "y":return new Date(date.getFullYear()+number,date.getMonth(),date.getDate()); break;
case "m":return new Date(date.getFullYear(),date.getMonth()+number,checkDate(date.getFullYear(),date.getMonth()+number,date.getDate())); break;
case "d":return new Date(date.getFullYear(),date.getMonth(),date.getDate()+number); break;
case "w":return new Date(date.getFullYear(),date.getMonth(),7*number+date.getDate()); break;
}
}
function checkDate(year,month,date){
var enddate = ["31","28","31","30","31","30","31","31","30","31","30","31"];
var returnDate = "";
if (year%4==0){enddate[1]="29"}
if (date>enddate[month]){returnDate = enddate[month]}else{returnDate = date}
return returnDate;
}
function WeekDay(date){
var theDate;
if (typeof(date)=="string"){theDate = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2]);}
if (typeof(date)=="object"){theDate = date}
return theDate.getDay();
}
function HS_calender(){
var lis = "";
var style = "";
/*可以把下面的css剪切出去独立一个css文件*/
style +="<style type='text/css'>";
style +=".calender { width:170px; height:auto; font-size:12px; margin-right:14px; background:url(calenderbg.gif) no-repeat right center #fff; border:1px solid #397EAE; padding:1px}";
style +=".calender ul {list-style-type:none; margin:0; padding:0;}";
style +=".calender .day { background-color:#EDF5FF; height:20px;}";
style +=".calender li { list-style-type: none; float: left; margin: 0 0px; padding: 0 !important; background: #ffffff; background-image: none !important;}";
style +=".calender .day li,.calender .date li{ float:left; width:14%; height:20px; line-height:20px; text-align:center}";
style +=".calender li a { text-decoration:none; font-family:Tahoma; font-size:11px; color:#333}";
style +=".calender li a:hover { color:#f30; text-decoration:underline}";
style +=".calender li a.hasArticle {font-weight:bold; color:#f60 !important}";
style +=".lastMonthDate, .nextMonthDate {color:#bbb;font-size:11px}";
style +=".selectThisYear a, .selectThisMonth a{text-decoration:none; margin:0 2px; color:#000; font-weight:bold}";
style +=".calender .LastMonth, .calender .NextMonth{ text-decoration:none; color:#000; font-size:18px; font-weight:bold; line-height:16px;}";
style +=".calender .LastMonth { float:left;}";
style +=".calender .NextMonth { float:right;}";
style +=".calenderBody {clear:both}";
style +=".calenderTitle {text-align:center;height:20px; line-height:20px; clear:both}";
style +=".today { background-color:#ffffaa;border:1px solid #f60; padding:2px}";
style +=".today a { color:#f30; }";
style +=".calenderBottom {clear:both; border-top:1px solid #ddd; padding: 3px 0; text-align:left}";
style +=".calenderBottom a {text-decoration:none; margin:2px !important; font-weight:bold; color:#000}";
style +=".calenderBottom a.closeCalender{float:right}";
style +=".closeCalenderBox {float:right; border:1px solid #000; background:#fff; font-size:9px; width:11px; height:11px; line-height:11px; text-align:center;overflow:hidden; font-weight:normal !important}";
style +="</style>";
var now;
if (typeof(arguments[0])=="string"){
selectDate = arguments[0].split("-");
var year = selectDate[0];
var month = parseInt(selectDate[1])-1+"";
var date = selectDate[2];
now = new Date(year,month,date);
}else if (typeof(arguments[0])=="object"){
now = arguments[0];
}
var lastMonthEndDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+now.getMonth()+"-01").getDate();
var lastMonthDate = WeekDay(now.getFullYear()+"-"+now.getMonth()+"-01");
var thisMonthLastDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-01");
var thisMonthEndDate = thisMonthLastDate.getDate();
var thisMonthEndDay = thisMonthLastDate.getDay();
var todayObj = new Date();
today = todayObj.getFullYear()+"-"+todayObj.getMonth()+"-"+todayObj.getDate();
for (i=0; i<lastMonthDate; i++){ // Last Month's Date
lis = "<li class='lastMonthDate'>"+lastMonthEndDate+"</li>" + lis;
lastMonthEndDate--;
}
for (i=1; i<=thisMonthEndDate; i++){ // Current Month's Date
if(today == now.getFullYear()+"-"+now.getMonth()+"-"+i){
var todayString = now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-"+i;
lis += "<li><a href=javascript:void(0) class='today' onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth())+1)+"-"+i+"'>"+i+"</a></li>";
}else{
lis += "<li><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth())+1)+"-"+i+"'>"+i+"</a></li>";
}
}
var j=1;
for (i=thisMonthEndDay; i<6; i++){ // Next Month's Date
lis += "<li class='nextMonthDate'>"+j+"</li>";
j++;
}
lis += style;
var CalenderTitle = "<a href='javascript:void(0)' class='NextMonth' onclick=HS_calender(HS_DateAdd('m',1,'"+now.getFullYear()+"-"+now.getMonth()+"-"+now.getDate()+"'),this) title='Next Month'>&raquo;</a>";
CalenderTitle += "<a href='javascript:void(0)' class='LastMonth' onclick=HS_calender(HS_DateAdd('m',-1,'"+now.getFullYear()+"-"+now.getMonth()+"-"+now.getDate()+"'),this) title='Previous Month'>&laquo;</a>";
CalenderTitle += "<span class='selectThisYear'><a href='javascript:void(0)' onclick='CalenderselectYear(this)' title='Click here to select other year' >"+now.getFullYear()+"</a></span>年<span class='selectThisMonth'><a href='javascript:void(0)' onclick='CalenderselectMonth(this)' title='Click here to select other month'>"+(parseInt(now.getMonth())+1).toString()+"</a></span>月";
if (arguments.length>1){
arguments[1].parentNode.parentNode.getElementsByTagName("ul")[1].innerHTML = lis;
arguments[1].parentNode.innerHTML = CalenderTitle;
}else{
var CalenderBox = style+"<div class='calender'><div class='calenderTitle'>"+CalenderTitle+"</div><div class='calenderBody'><ul class='day'><li>日</li><li>一</li><li>二</li><li>三</li><li>四</li><li>五</li><li>六</li></ul><ul class='date' id='thisMonthDate'>"+lis+"</ul></div><div class='calenderBottom'><a href='javascript:void(0)' class='closeCalender' onclick='closeCalender(this)'>&times;</a><span><span><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+todayString+"'>Today</a></span></span></div></div>";
return CalenderBox;
}
}
function _selectThisDay(d){
var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode;
boxObj.targetObj.value = d.title;
boxObj.parentNode.removeChild(boxObj);
}
function closeCalender(d){
var boxObj = d.parentNode.parentNode.parentNode;
boxObj.parentNode.removeChild(boxObj);
}
function CalenderselectYear(obj){
var opt = "";
var thisYear = obj.innerHTML;
for (i=1970; i<=2020; i++){
if (i==thisYear){
opt += "<option value="+i+" selected>"+i+"</option>";
}else{
opt += "<option value="+i+">"+i+"</option>";
}
}
opt = "<select onblur='selectThisYear(this)' onchange='selectThisYear(this)' style='font-size:11px'>"+opt+"</select>";
obj.parentNode.innerHTML = opt;
}
function selectThisYear(obj){
HS_calender(obj.value+"-"+obj.parentNode.parentNode.getElementsByTagName("span")[1].getElementsByTagName("a")[0].innerHTML+"-1",obj.parentNode);
}
function CalenderselectMonth(obj){
var opt = "";
var thisMonth = obj.innerHTML;
for (i=1; i<=12; i++){
if (i==thisMonth){
opt += "<option value="+i+" selected>"+i+"</option>";
}else{
opt += "<option value="+i+">"+i+"</option>";
}
}
opt = "<select onblur='selectThisMonth(this)' onchange='selectThisMonth(this)' style='font-size:11px'>"+opt+"</select>";
obj.parentNode.innerHTML = opt;
}
function selectThisMonth(obj){
HS_calender(obj.parentNode.parentNode.getElementsByTagName("span")[0].getElementsByTagName("a")[0].innerHTML+"-"+obj.value+"-1",obj.parentNode);
}
function HS_setDate(inputObj){
var calenderObj = document.createElement("span");
calenderObj.innerHTML = HS_calender(new Date());
calenderObj.style.position = "absolute";
calenderObj.targetObj = inputObj;
inputObj.parentNode.insertBefore(calenderObj,inputObj.nextSibling);
}
//lizanle 刷新函数
function redo() {
window.location.reload()
}

View File

@ -2917,4 +2917,34 @@ input[class~='m3p10'], .m3p10 {
display: inline-block;
color: #ffffff;
cursor:pointer;
}
/*lizanle 日誌搜索結果樣式*/
.search_results {
color: red;
}
/*lizanle 分页样式*/
.pagination ul li a, .pagination ul li span{
background-color: #FFFFFF;
border-color: #DDDDDD;
border-image: none;
border-style: solid;
border-width: 1px 1px 1px 1px;
float: left;
line-height: 20px;
padding: 4px 12px;
text-decoration: none;
}
.pagination ul a {
color: #9B9B9B;
}
.pagination ul li a:hover, .pagination ul li a:focus, .pagination ul .active a, .pagination ul .active span{
background-color: #ffc02f;
border: 1px solid #ffc02f;
}
.pagination ul li{
float: left;
margin-right: 3px;
list-style: none outside none;
}

View File

@ -0,0 +1,7 @@
require 'test_helper'
class SystemLogControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class ExpireHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class SystemLogHelperTest < ActionView::TestCase
end

View File

@ -1 +0,0 @@
Put your Redmine plugins here.