Plugins Directory » Default queries per project

Author: Vitaly Klimov
Website: http://www.redmine.org/boards/3/topics/11764
Code repository: -
Registered on: 2011-02-08 (over 6 years ago)
Current version: 0.1.1
Compatible with: Redmine 1.3.x, 1.4.x, 2.0.x
User ratings:   (3)

Default queries per project

Plugin allows to apply default queries for individual project or for projects based on their type.
Also it allows users to define their own default queries for each project or for all projects.

Features

  • Uses existing query system thus providing compatibility with future Redmine versions
  • Allows to define default query on project by project basis
  • Allows to define default global query for displaying all issues
  • Allows to define default query based on project custom field value
  • Allows to define user his/hers own default queries for each project
  • Allows to define user his/hers global query for displaying all issues
  • Allows to define user query that will be applied individually for each user allowing to directly jump to project and apply specefic query upon logon

Details

This plugin is very useful if you are using Redmine projects for more than one purpose. For example, we have projects for bug-tracking as well as for project management and invoice tracking. I was really missing the ability to define default query for project or group of projects - and without it it was very inconvenient to create set of public queries which you had manually apply each time you switch projects.

Also in latest versions plugin allows to define default view for each user - which is very handy, because columns to display could differ from user to user.

This plugin came as an answer to my own request #3967 (http://www.redmine.org/issues/3967)

Logic behind the plugin

First of all - plugin uses existing queries system thus (hopefully) maintaining maximal compatibility with further Redmine versions. It uses existing queries and small patch to the Issues Controller to apply default query if no query is defined.

Plugin retrieves queries from dedicated project (defined in settings) and applies them to the current project.

I would advise to create dedicated project which will hold all the necessary types of queries. This project has to include all trackers and all custom fields to make all the types of queries possible.

For user defined default queries plugin uses name, defined in settings (MyDefault by default) for projects and MyGlobal (by default) for all issues.

For redirection to user defined project with user defined query, MyHome query searched by default (redefinable in settings)

Please note that all user queries should not be public.

How it works

There are several nested levels by which default query is determined

If issues from all projects are displayed

  • If the project has query with the name defined in plugin settings (field Default user global query name) which belongs to logged user, plugin uses this query as a default query
  • Query with name Global_Default is retrieved from project defined in the drop down named Project with default queries (on the plugin settings screen) and applied to all issues display
  • If there are no such query exist then plugin does nothing

If issues from specific project are displayed

  • If the project has query with the name defined in plugin settings (field Default user query name) which belongs to logged user plugin uses this query as a default query
  • If the project has query with the name defined in plugin settings (field Default query name) plugin uses this query as a default query
  • If no such query exists in project, value of project custom field (defined in drop down Custom field to define type on the plugin settings screen) appended to the string Default_ to create query name
  • If no such custom field exists, value Default_Project used for query name
  • After that query with such name is retrieved from project defined in the drop down named Project with default queries (on the plugin settings screen)
  • If there are no such query exist then plugin does nothing

Also plugin defines controller named query_per_project and action redirect_to_user_query

When invoked, it searches for query named MyHome (by default, redifinable in settings) which belongs to current user and redirects to this project, applying this query. It can be convenietly used with redmine_homepage plugin by Eric Davis

Also it substitutes views/issues/index.rhtml to collapse filters pane when any of the queries above applied.

Example of usage

For example, we have projects of three several types - one for bug-tracking, another one for PM and another one for invoices. Also we have one special project named 'SpecialCase' for whom we want to have its own default query.

Step by step tutorial

  • Create special project which will hold all our default queries (lets call it 'DefaultQueries') We should include all possible trackers and issues' custom fields to this project to be able to create queries for all our projects
  • Create project custom field which will hold project type (lets make it drop-down named 'Type' with values 'Bugs', 'Invoices' and 'Tasks'). To make things easier we'll make it required for all projects with the default value of 'Tasks'
  • Set this custom field for each project according to the project type
  • Go to plugin settings and select project we created (DefaultQueries) and custom field name (Type). We will leave value for the 'Default query name' as it was - 'Default'
  • Go to the project 'DefaultQueries' and create there three queries named 'Default_Bugs', 'Default_Tasks' and 'Default_Invoices' For each query we can use its own set of columns/sort order/grouping
  • Go to the project 'SpecialCase' and create query named 'Default'

We all set for now.

What would happen if we will decide to view issues in the project with custom field 'Type' set to 'Bugs'? Plugin will lookup query named 'Default_Bugs' in project 'DefaultQueries' and apply it to the issues view! Same will be done for projects with type 'Tasks' and 'Invoices' - queries named 'Default_Tasks' and 'Default_Invoices' will be applied to their views. If we will choose project named 'SpecialCase' the query named 'Default' will be applied because it exists there regardless of the project type.

Installation notes

  1. Please do remove folder redmine_default_columns completely before installing new version
  2. Install plugin Plugin views with revisions if you do not have it installed
  3. Follow the Redmine plugin installation steps at: http://www.redmine.org/wiki/redmine/Plugins
  4. Run rake task
    rake redmine:plugins:process_version_change RAILS_ENV=production
  5. Restart your Redmine web servers (e.g. mongrel, thin, mod_rails)
  6. Login as administrator and configure the plugin (Administration > Plugins > Configure)

Changelog

0.1.1 (2012-06-15)

Compatible with Redmine 1.3.x, 1.4.x, 2.0.x.

  • Rails 3 (Redmine 2.x) compatibility

redmine_default_columns_v011.zip (23 KB) Vitaly Klimov, 2012-06-15 18:01

0.1.0 (2012-06-07)

Compatible with Redmine 1.3.x, 1.4.x, 2.0.x.

redmine_default_columns_v010.zip (21.8 KB) Vitaly Klimov, 2012-06-07 18:29

0.0.8 (2012-03-07)

Compatible with Redmine 1.3.x.

  • Patches QueriesHelper differently for more compatibility
  • Now compatible with BetterGanttChart plugin

redmine_default_columns_v008.zip (19.4 KB) Vitaly Klimov, 2012-03-07 09:05

0.0.7 (2012-02-23)

Compatible with Redmine 1.3.x.

  • Compatibility with Redmine 1.3.0 added
  • Does not compatible with previous versions of Redmine

redmine_default_columns_v007.zip (19 KB) Vitaly Klimov, 2012-02-23 14:09

0.0.6 (2011-07-25)

Compatible with Redmine 1.2.x.

Plugin version which compatible with 1.2.x releases. This version does not support previous Redmine versions (prior to 1.2.0)

redmine_default_columns_v006.zip - Version compatible with 1.2.x (18.2 KB) Vitaly Klimov, 2011-07-25 16:24

0.0.5 (2011-02-08)

Compatible with Redmine 0.9.x, 1.0.x, 1.1.x.

redmine_default_columns_v005.zip (17.8 KB) Vitaly Klimov, 2011-02-08 17:15

User ratings

  by dj jones about 1 year ago

there is a version that works with Redmine 3 at
- http://www.redmine.org/boards/3/topics/11764?page=4

  by W K over 1 year ago

This is great idea!

Can someone confirm that this plugin works with Redmine 2.6.10.stable? Form me it won't :(

  by Olivier Houdas over 3 years ago

Very useful to filter Issues directly on those we want to see rather than having to click first on Issues, then on a saved query