From 3f3fdf2a2d10bf77190c5415644fffbde3f47397 Mon Sep 17 00:00:00 2001
From: Mathieu MARQUET
Date: Fri, 28 Jul 2017 13:54:16 +0200
Subject: [PATCH] Add a setting that allows to calculate progress based on
tickets ratio and not the hours spent/projection
---
README.md | 46 ++++---------------
.../projects/_progressive_sidebar.html.erb | 6 +--
.../_progressive_projects_list.html.erb | 8 ++--
config/locales/en.yml | 4 +-
config/locales/fr.yml | 8 ++--
init.rb | 9 ++--
lib/progressive/project_decorator.rb | 28 +++++++----
7 files changed, 45 insertions(+), 64 deletions(-)
diff --git a/README.md b/README.md
index 425f783..83e7fd7 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,18 @@
Progressive Projects List
=========================
-[](http://www.redmine.org/plugins/progressive-projects-list)
-
-Plugin loads [Redmine](http://www.redmine.org/)'s projects list with overall projects status.
-
-One of the [5 Redmine Plugins that will change the way you work](http://it-consultis.com/blog/5-redmine-plugins-will-change-way-work/) by [Thomas Guillemaud](http://it-consultis.com/author/thomas/) from [IT Consultis]
-(http://it-consultis.com/).
+Projects list with blackjack and other features for [Redmine](http://www.redmine.org/).
Features
--------
-- Show overall projects status in progress bars
+- Show overall projects status in progress bars (progress can be calculated based on the hours spent/left or simply on the ratio of tickets closed - configurable)
- Show project status in progress bars at project overview page
- Quick links to issues, new issue, version, etc directly from the projects list
- Show due date of the projects and versions
- Recently viewed projects sidebar block
- Configurable: admin set default settings, user may override them per session
-- Translated into 12 languages: English, German, French, Italian, Spanish, Portuguese, Traitional and Simplified Chinese, Japanese, Russian, Ukrainian, Polish.
+- Translated into 7 languages: English, German, French, Italian, Simplified Chinese, Russian, Ukrainian.

@@ -26,38 +21,15 @@ More details and screenshots - http://stgeneral.github.io/redmine-progressive-pr
Installation notes
------------------
-1. Download [latest release](https://github.com/stgeneral/redmine-progressive-projects-list/releases/latest) of the plugin.
-2. Extract it to `/plugins`. You should get `/plugins/progressive_projects_list` directory.
-3. Restart Redmine.
-
-You should now be able to see the plugin list in _Administration -> Plugins_ and configure it.
+Plugin's directory should be named progressive_projects_list exactly.
+Other installation instructions are generic and can be found at [Redmine Plugins page](http://www.redmine.org/projects/redmine/wiki/Plugins).
-Generic instructions for installing/uninstalling plugins can be found at [Redmine Plugins page](http://www.redmine.org/projects/redmine/wiki/Plugins).
+Compatible with Redmine 2.4, 2.3, 2.2, 2.1.
+For ChiliProject 3.4 use [version 0.5.1](https://github.com/stgeneral/redmine-progressive-projects-list/releases/tag/v0.5.1).
-### Compatibility ###
-
-- Redmine 3.0 .. 3.2 - [version 3.0.1](https://github.com/stgeneral/redmine-progressive-projects-list/releases/tag/v3.0.1) and branch [master](https://github.com/stgeneral/redmine-progressive-projects-list/tree/master).
-- Redmine 2.3 .. 3.0 - [version 2.0.1](https://github.com/stgeneral/redmine-progressive-projects-list/releases/tag/v2.0.1).
-- Redmine 2.1 .. 2.6 - [version 1.1.0](https://github.com/stgeneral/redmine-progressive-projects-list/releases/tag/v1.1.0) and branch [version-1](https://github.com/stgeneral/redmine-progressive-projects-list/tree/version-1).
-- ChiliProject 3.4 - [version 0.5.1](https://github.com/stgeneral/redmine-progressive-projects-list/releases/tag/v0.5.1) and branch [version-0](https://github.com/stgeneral/redmine-progressive-projects-list/tree/version-0).
-
-Proressive plugins for Redmine
-------------------------------
+Other Proressive plugins for Redmine
+------------------------------------
* [Progressive Projects List](http://stgeneral.github.io/redmine-progressive-projects-list/) - overall projects status on one page.
* [Progressive Redmine Theme](http://stgeneral.github.io/redmine-progressive-theme/) - extends default theme with some nice features.
* [Progressive Gantt Mods](http://stgeneral.github.io/redmine-progressive-gantt-mods/) - assignee column and some preferences for Gantt chart.
-* [Collapsed Journals Plugin](https://github.com/stgeneral/redmine-collapsed-journals) - collapses issue history items without an assosiated note
-
-License
--------
-
-*The MIT License (MIT)*
-
-Copyright (c) 2012-2016 Dmitry Babenko
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/app/views/projects/_progressive_sidebar.html.erb b/app/views/projects/_progressive_sidebar.html.erb
index 63db422..30f32ba 100644
--- a/app/views/projects/_progressive_sidebar.html.erb
+++ b/app/views/projects/_progressive_sidebar.html.erb
@@ -9,9 +9,9 @@
<%= check_box_tag :show_project_progress, 1, progressive_setting?(:show_project_progress) %>
<%= label_tag :show_project_progress, l(:setting_show_project_progress) %>
<%= check_box_tag :show_only_for_my_projects, 1, progressive_setting?(:show_only_for_my_projects) %>
- <%= label_tag :show_only_for_my_projects, l(:setting_show_only_for_my_projects) %>
- <%= check_box_tag :show_recent_projects, 1, progressive_setting?(:show_recent_projects) %>
- <%= label_tag :show_recent_projects, l(:setting_show_recent_projects) %>
+ <%= label_tag :show_only_for_my_projects, l(:setting_show_only_for_my_projects) %>
+ <%= check_box_tag :ignore_hours, 1, progressive_setting?(:ignore_hours) %>
+ <%= label_tag :ignore_hours, l(:setting_ignore_hours) %>
<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>
<% end %>
diff --git a/app/views/settings/_progressive_projects_list.html.erb b/app/views/settings/_progressive_projects_list.html.erb
index b20ab4e..4639aad 100644
--- a/app/views/settings/_progressive_projects_list.html.erb
+++ b/app/views/settings/_progressive_projects_list.html.erb
@@ -16,6 +16,10 @@
<%= setting_label(:show_only_for_my_projects) %>
<%= check_box_tag('settings[show_only_for_my_projects]', true, @settings['show_only_for_my_projects']) %>
+
+ <%= setting_label(:ignore_hours) %>
+ <%= check_box_tag('settings[ignore_hours]', true, @settings['ignore_hours']) %>
+
<%= setting_label(:show_project_progress_overview) %>
<%= select_tag('settings[show_project_progress_overview]',
@@ -25,8 +29,4 @@
[l(:progressive_option_right), 'right']],
@settings['show_project_progress_overview'])) %>
-
- <%= setting_label(:show_recent_projects) %>
- <%= check_box_tag('settings[show_recent_projects]', true, @settings['show_recent_projects']) %>
-
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0d220c7..4168132 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -4,9 +4,9 @@ en:
setting_show_project_progress_overview: Show progress on overview page
setting_show_project_menu: Show projects' menu
setting_show_only_for_my_projects: Show only for my projects
- setting_show_recent_projects: Show 'Recently viewed projects'
+ setting_ignore_hours: Compute progress projects by ignoring hours spent on issues
progressive_settings_hint: Defaults settings. Users may override them per session.
label_progress: Progress
progressive_option_left: Left
progressive_option_right: Right
- label_recent_projects: Recently viewed projects
+ label_recent_projects: Recently viewed projects
\ No newline at end of file
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index ef41b46..08fd217 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -1,12 +1,12 @@
fr:
setting_show_project_description: Afficher la description des projets
setting_show_project_progress: Afficher la progression des projets
- setting_show_project_progress_overview: Afficher la progression sur la page d'aperçu
+ setting_show_project_progress_overview: Afficher le progrès dans la fenêtre d'aperçu
setting_show_project_menu: Afficher le menu des projets
setting_show_only_for_my_projects: Afficher seulement pour mes projets
- setting_show_recent_projects: Afficher 'Projets vus récemment'
+ setting_ignore_hours: Calculer le progrès du projet en ignorant les heures imputées
progressive_settings_hint: Configuration par défaut. Les utilisateurs peuvent la modifier pendant leur session courante.
- label_progress: Progression
+ label_progress: Progrès
progressive_option_left: à gauche
progressive_option_right: à droite
- label_recent_projects: Projets vus récemment
+ label_recent_projects: Projets vus récemment
\ No newline at end of file
diff --git a/init.rb b/init.rb
index 8761539..9ac346c 100644
--- a/init.rb
+++ b/init.rb
@@ -6,23 +6,22 @@
name 'Progressive Projects List plugin'
author 'Dmitry Babenko'
description 'Projects List with menus and progress bars.'
- version '3.0.1'
+ version '1.0.0'
url 'http://stgeneral.github.io/redmine-progressive-projects-list/'
author_url 'https://github.com/stgeneral'
- requires_redmine :version_or_higher => '3.0'
+ requires_redmine :version_or_higher => '2.1.0'
settings :default => {
'show_project_description' => false,
'show_project_progress' => true,
'show_project_menu' => false,
'show_only_for_my_projects' => false,
- 'show_recent_projects' => true,
- 'show_project_progress_overview' => ''
+ 'show_project_progress_overview' => '',
+ 'ignore_hours' => false
}, :partial => 'settings/progressive_projects_list'
end
require 'progressive_projects_list'
-require 'progressive/application_helper_patch'
require 'progressive/projects_helper_patch'
require 'progressive/projects_list_view_listener'
require 'progressive/recent_projects_view_listener'
diff --git a/lib/progressive/project_decorator.rb b/lib/progressive/project_decorator.rb
index 66e1243..798025b 100644
--- a/lib/progressive/project_decorator.rb
+++ b/lib/progressive/project_decorator.rb
@@ -24,25 +24,35 @@ def issues_progress(open)
@issues_progress ||= {}
@issues_progress[open] ||= begin
progress = 0
- if issues.count > 0
- ratio = open ? 'done_ratio' : 100
+ if Setting.plugin_progressive_projects_list['ignore_hours']
+ progress = 100 * (issues.count - issues.open.count) / (issues.count)
+ puts progress
+ else
+ if issues.count > 0
+ ratio = open ? 'done_ratio' : 100
- done = issues.joins(:status).where("#{IssueStatus.table_name}.is_closed=?",!open)
- .sum("COALESCE(CASE WHEN estimated_hours > 0 THEN estimated_hours ELSE NULL END, #{estimated_average}) * #{ratio}").to_f
- progress = done / (estimated_average * issues.count)
+ done = issues.sum("COALESCE(CASE WHEN estimated_hours > 0 THEN estimated_hours ELSE NULL END, #{estimated_average}) * #{ratio}",
+ :joins => :status,
+ :conditions => ["#{IssueStatus.table_name}.is_closed = ?", !open]).to_f
+ progress = done / (estimated_average * issues.count)
+ end
end
progress
end
end
- # Cloned from Version#completed_percent
+ # Cloned from Version#completed_pourcent
def issues_completed_percent
if issues.count == 0
0
elsif issues.open.count == 0
100
else
- issues_progress(false) + issues_progress(true)
+ if Setting.plugin_progressive_projects_list['ignore_hours']
+ issues_progress(true)
+ else
+ issues_progress(false) + issues_progress(true)
+ end
end
end
@@ -50,8 +60,8 @@ def issues_completed_percent
def opened_due_date
@opened_due_date ||= [
issues.open.maximum('due_date'),
- shared_versions.open.maximum('effective_date'),
- Issue.open.fixed_version(shared_versions.open).maximum('due_date')
+ shared_versions.maximum('effective_date'),
+ Issue.fixed_version(shared_versions).maximum('due_date')
].compact.max
end
end