From ccd3bf2c87b4810d13223e77a26d6f1e25367207 Mon Sep 17 00:00:00 2001 From: OZAWA Yasuhiro Date: Sun, 4 Oct 2015 20:50:55 +0900 Subject: [PATCH] =?UTF-8?q?3.0=E3=80=813.1=E3=81=AB=E4=BB=AE=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.rdoc | 10 +++++++--- app/models/already_read.rb | 9 +++++---- init.rb | 2 +- lib/already_read/issue_patch.rb | 2 +- lib/already_read/issues_controller_patch.rb | 2 +- lib/already_read/user_patch.rb | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.rdoc b/README.rdoc index 8fcf1f3..748243d 100644 --- a/README.rdoc +++ b/README.rdoc @@ -3,14 +3,14 @@ チケットの既読/未読を管理し、チケット一覧に「既読」「読んだ日時」列を追加します。 チケットを更新すると、そのチケットは未読チケットに戻ります。 -Redmine2.5.1で簡単な動作確認したのみ。 +Redmine3.0.5、3.1.1で簡単な動作確認したのみ。 == インストール 1. RAILS_ROOT/pluginsに配置する。 -2. rake db:migrate_plugins RAILS_ENV=production +2. rake redmine:plugins:migrate RAILS_ENV=production を実行する。 3. Redmineを再起動する。 @@ -19,7 +19,7 @@ Redmine2.5.1で簡単な動作確認したのみ。 == アンインストール 1. RAILS_ROOTで - rake db:migrate:plugin RAILS_ENV=production VERSION=0 NAME=redmine_already_read + rake redmine:plugins:migrate RAILS_ENV=production VERSION=0 NAME=redmine_already_read を実行する。 2. RAILS_ROOT/pluginsから削除する。 @@ -37,6 +37,10 @@ Redmine2.5.1で簡単な動作確認したのみ。 == 更新履歴 +=== Version 0.0.5 + +3.0、3.1に仮対応。 + === Version 0.0.4 2.3のクエリの実装変更に仮対応。 diff --git a/app/models/already_read.rb b/app/models/already_read.rb index fb57a2c..c7aecc5 100644 --- a/app/models/already_read.rb +++ b/app/models/already_read.rb @@ -10,13 +10,14 @@ class AlreadyRead < ActiveRecord::Base :author => :user, :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id}} - acts_as_activity_provider :find_options => {:include => [ {:issue => [:project, :tracker, :status]}, :user ]}, + acts_as_activity_provider :scope => preload({:issue => [:project, :tracker, :status]}, :user), :author_key => :user_id, :type => 'issues' # "活動"で参照するための閲覧スコープ - scope :visible, - lambda {|*args| { :include => {:issue => :project}, - :conditions => Issue.visible_condition(args.shift || User.current, *args) } } + scope :visible, lambda {|*args| + joins(:issue => :project). + where(Issue.visible_condition(args.shift || User.current, *args)) + } # 状態の説明 # "活動"で参照する diff --git a/init.rb b/init.rb index 5fb9352..74b76da 100644 --- a/init.rb +++ b/init.rb @@ -8,7 +8,7 @@ name 'Redmine Already Read plugin' author 'OZAWA Yasuhiro' description 'Markup read issues.' - version '0.0.4' + version '0.0.5' url 'https://github.com/ameya86/redmine_already_read' author_url 'http://blog.livedoor.jp/ameya86/' diff --git a/lib/already_read/issue_patch.rb b/lib/already_read/issue_patch.rb index 36136e4..418aa8e 100644 --- a/lib/already_read/issue_patch.rb +++ b/lib/already_read/issue_patch.rb @@ -20,7 +20,7 @@ def css_classes_with_already_read end class Issue < ActiveRecord::Base - has_many :already_reads, :include => [:user], :order => :created_on + has_many :already_reads, lambda {includes(:user); order(:created_on)} has_many :already_read_users, :through => :already_reads, :source => :user after_update :reset_already_read diff --git a/lib/already_read/issues_controller_patch.rb b/lib/already_read/issues_controller_patch.rb index ff4b23d..e3b6318 100644 --- a/lib/already_read/issues_controller_patch.rb +++ b/lib/already_read/issues_controller_patch.rb @@ -1,7 +1,7 @@ require_dependency 'issues_controller' class IssuesController < ApplicationController - after_filter :issue_read, :only => [:show] + after_action :issue_read, :only => [:show] private # 既読フラグを付ける diff --git a/lib/already_read/user_patch.rb b/lib/already_read/user_patch.rb index 63bbaae..22b7406 100644 --- a/lib/already_read/user_patch.rb +++ b/lib/already_read/user_patch.rb @@ -2,6 +2,6 @@ require_dependency 'user' class User < Principal - has_many :already_reads, :order => :created_on + has_many :already_reads, lambda {order(:created_on)} has_many :already_read_issues, :through => :already_reads, :source => :issue end