Guest User

Untitled

a guest
Jan 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. # encoding: utf-8
  2.  
  3. # find_by_status_history.rb
  4. #
  5. # Redmineのチケットのうち、特定のステータスに設定されたことがある
  6. # チケットを検索します。
  7. #
  8. # 使い方:
  9. # Redmineのインストールディレクトリで以下のように実行。
  10. #
  11. # PROJECT=プロジェクト識別子 STATUS=ステータス名 script/runner -e production find_by_status_history.rb
  12. #
  13.  
  14. project_identifier = ENV['PROJECT']
  15. status_name = ENV['STATUS'] || 'フィードバック'
  16. project = Project.find_by_identifier(project_identifier)
  17. feedback_status = IssueStatus.find_by_name(status_name)
  18.  
  19. feedbacked_issues = JournalDetail.find(
  20. :all,
  21. :conditions => ['prop_key = "status_id" and journalized_type = "Issue" and value = ? and project_id = ?', feedback_status.id, project.id],
  22. :joins => 'inner join (journals, issues) on (journal_id = journals.id and journals.journalized_id = issues.id)',
  23. :order => 'issues.id').map {|jd| jd.journal.issue}.uniq
  24.  
  25. feedbacked_issues.each do |issue|
  26. puts "##{issue.id}\t#{issue.subject}"
  27. end
Add Comment
Please, Sign In to add comment