プロジェクトのチケットで、他の形式にエクスポートのAtomを選択した際に、更新日でなく作成日がエクスポートされてしまう問題の回避

533 views
Skip to first unread message

MASAKI SHIMIZU

unread,
Aug 7, 2020, 5:32:14 AM8/7/20
to Redmine Users (japanese)
プロジェクトのチケット更新時にAtomを利用して、slackのRSSアプリとの連携による通知を使ってます。
チケット更新時に通知を行いたいのですが、<updated>~</updated>の日時がチケット作成日になってしまい、チケット新規登録時にしか通知が飛ばなくて困っております。
Rails周りの知識がない(Rubyは問題ない)ため、何をどうデバッグして、対処すべきかわからないので、ヘルプ頂けませんでしょうか?

以下、環境情報です。

Environment:
  Redmine version                4.1.1.stable
  Ruby version                   2.6.6-p146 (2020-03-31) [x86_64-linux]
  Rails version                  5.2.4.2
  Environment                    production
  Database adapter               PostgreSQL
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
SCM:
  Subversion                     1.10.2
  Git                            2.18.4
  Filesystem                     
Redmine plugins:
  easy_gantt                     1.12
  kanban                         0.0.7
  redmine_absolute_dates         0.0.4
  redmine_banner                 0.3.3
  redmine_checklists             3.1.16
  redmine_close_button           0.0.8
  redmine_enter_cancel           0.0.2
  redmine_knowledgebase          4.1.1
  redmine_slack                  0.2
  view_customize                 2.6.0

Tatsuya Saito

unread,
Aug 8, 2020, 3:25:39 AM8/8/20
to Redmine Users (japanese)
齋藤達也です。こんにちは。

ちょっと調べてみたところ、
 app/views/common/feed.atom.builder
でatomを作っています。
 xml.updated item.event_datetime.xmlschema
updatedタグを出力していますが、これは、
 lib/plugins/acts_as_event/lib/acts_as_event.rb
でデフォルトが
    default_options = { :datetime => :created_on,
となっており、作成日時が出ているようです。

以下のような感じで修正したところ、チケットを更新すると
atomのupdatedも更新されました。

Index: app/models/issue.rb
===================================================================
--- app/models/issue.rb (revision 19891)
+++ app/models/issue.rb (working copy)
@@ -49,7 +49,8 @@

   acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
                 :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
-                :type => Proc.new {|o| 'issue' + (o.closed? ? '-closed' : '') }
+                :type => Proc.new {|o| 'issue' + (o.closed? ? '-closed' : '') },
+                :datetime => Proc.new {|o| o.updated_on }

   acts_as_activity_provider :scope => preload(:project, :author, :tracker, :status),
                             :author_key => :author_id

参考になればと思います。


2020年8月7日金曜日 18時32分14秒 UTC+9 MASAKI SHIMIZU:

Tatsuya Saito

unread,
Aug 8, 2020, 11:32:43 AM8/8/20
to Redmine Users (japanese)
齋藤達也です。
記載していたパッチだと、活動での表示がおかしくなってしまいました。
redmine.orgにチケットを発行して、そちらにパッチをはりました。

場当たり的な感じになってしまっていますが、参考になればと思います。

--
齋藤達也(Tatsuya Saito)
twitter:@two_pack


2020年8月8日土曜日 16時25分39秒 UTC+9 Tatsuya Saito:
Reply all
Reply to author
Forward
0 new messages