Created
September 21, 2011 05:27
-
-
Save vividtone/1231320 to your computer and use it in GitHub Desktop.
Redmineのチケットのうち、特定のステータスに設定されたことがあるものを検索して一覧表示する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# find_by_status_history.rb | |
# | |
# Redmineのチケットのうち、特定のステータスに設定されたことがある | |
# チケットを検索します。 | |
# | |
# 使い方: | |
# Redmineのインストールディレクトリで以下のように実行。 | |
# | |
# PROJECT=プロジェクト識別子 STATUS=ステータス名 script/runner -e production find_by_status_history.rb | |
# | |
project_identifier = ENV['PROJECT'] | |
status_name = ENV['STATUS'] || 'フィードバック' | |
project = Project.find_by_identifier(project_identifier) | |
feedback_status = IssueStatus.find_by_name(status_name) | |
feedbacked_issues = JournalDetail.find( | |
:all, | |
:conditions => ['prop_key = "status_id" and journalized_type = "Issue" and value = ? and project_id = ?', feedback_status.id, project.id], | |
:joins => 'inner join (journals, issues) on (journal_id = journals.id and journals.journalized_id = issues.id)', | |
:order => 'issues.id').map {|jd| jd.journal.issue}.uniq | |
feedbacked_issues.each do |issue| | |
puts "##{issue.id}\t#{issue.subject}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment