Some features of RedMine are not available for doing reporting. So I started to dig into the console interface and ran some of my own queries:

Starting the RedMine console

To start the RedMine console, change directories to your application base:

cd /usr/share/redmine-1.2

Now run the following command to get into the console:

RAILS_ENV=production ./script/console

This will get you into the Production side of your environment. If you want to use development area:

RAILS_ENV=development ./script/console

Running some queries

Find all issues by their description only

Issue.find(:all, :conditions => "description LIKE '%your_pattern%'")

Find all issues by their description only limited by project id

Issue.find(:all, :conditions => "description LIKE '%your_pattern%' AND project_id = '5'")

Find spent hours by looking for a custom value in a issue

hours = []
CustomValue.find(:all, :conditions => "custom_field_id = 35 AND value LIKE '%your_pattern%'").each do |c|
hours << Issue.find(c.customized_id).spent_hours
end

Find all issues that a specific user has commented on

user_id = []
Project.find(5).issues.each do |issue|
  issue.journals.each do |journal|
  if journal.user_id == 2
    user_id << issue.id
  end
end

Find list of users who contributed to an issue for a specific project

results = Hash.new
Project.find(5).issues.find(:all).each do |issue|
  people = []
  issue.journals.each do |j|
    people << user
  end
  results["#{issue}"] = people unless people.empty?
end
y results
comments powered by Disqus