Skip to content

Commit

Permalink
Merge pull request #222 from momibun926/redmine5.0
Browse files Browse the repository at this point in the history
Redmine5.0
  • Loading branch information
momibun926 authored May 3, 2022
2 parents 7402302 + 59cda40 commit 8e10a60
Show file tree
Hide file tree
Showing 17 changed files with 399 additions and 409 deletions.
15 changes: 9 additions & 6 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
This plugin provides the function of calculating evm of projects . EVM can help you to track your project progress and its status and to forecast the future performance of the project.

## Current Version
5.6.0
6.0.0

## Compatibility
Redmine 4.0.0 and above
Redmine 5.0.0 and above

> *Notification*
>
> The redmine3.4.x compatible version in branch "redmine3-4-3".
> https://github.com/momibun926/redmine_issue_evm/tree/redmine3-4-3
>
> The redmine4.x.x compatible version in branch "redmine4.0".
> https://github.com/momibun926/redmine_issue_evm/tree/redmine4.0
# Main features
* Calculate EVM with chart
Expand Down Expand Up @@ -129,7 +132,7 @@ In Japan, May 3, May 4, May 5 are holidays
|May 3, 2017 (Wed) |May 7, 2017 (Sunday)|20 hours |5 days |4 hours |

# Chart
Charts are displayed using Chart.js. This java scripts include Redmine.
Chart.js is used to display charts, and Chart.bundle.min.js used in Redmine 4.2 is included with this plugin.

**Main chart**

Expand Down Expand Up @@ -205,9 +208,9 @@ rake redmine:plugins:migrate NAME=redmine_issue_evm VERSION=0
5. Create new Pull Request

# My Environment
* Redmine version 4.2.4.stable.21433
* Ruby version 2.7.4-p191 (2021-07-07) [x86_64-linux]
* Rails version 5.2.6.2
* Redmine version 5.0.0.stable.21553
* Ruby version 3.1.2-p20 (2022-04-12) [x86_64-linux]
* Rails version 6.1.5.1
* Environment production
* Database adapter PostgreSQL
* Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
Expand Down
18 changes: 10 additions & 8 deletions README_ja.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
チケットの開始日、期日、予定工数、作業時間を利用してEVM値の計算とチャートを表示する機能を提供しています。期日が入力されず、バージョンの期日がある場合は、期日としてバージョンの期日を利用します。

# バージョン
5.6.0
6.0.0

# 動作環境
Redmine 4.0.0 以上
Redmine 5.0.0 以上

> *redmine3.4.xをお使いの方へ*
> *redmine5以外をお使いの方へ*
>
> Redmine3.4.xの対応版は、ブランチ"Redmine3-4-3"を取得してください。
>
> https://github.com/momibun926/redmine_issue_evm/tree/redmine3-4-3
>
> Redmine4.x.xの対応版は、ブランチ"Redmine4.0"を取得してください。
> https://github.com/momibun926/redmine_issue_evm/tree/redmine4.0
# 主な機能
* EVM値の計算
Expand Down Expand Up @@ -133,7 +135,7 @@ Redmine3.1から親チケットの予定工数が入力可能になったので

# チャートの表示
計算されたEVM値を元に、以下のチャートを表示します。
チャートの表示には、Chart.jsを利用しています。Redmineに同梱されているものを利用しています
チャートの表示には、Chart.jsを利用しています。Redmine4.2で利用されていたChart.bundle.min.jsをこのプラグインインように同梱しています

**メインチャート**

Expand Down Expand Up @@ -199,9 +201,9 @@ rake redmine:plugins:migrate NAME=redmine_issue_evm VERSION=0
![evm sample screenshot](./images/screenshot_common_setting.png "plugin setting")

# 開発環境
* Redmine version 4.2.4.stable.21433
* Ruby version 2.7.4-p191 (2021-07-07) [x86_64-linux]
* Rails version 5.2.6.2
* Redmine version 5.0.0.stable.21553
* Ruby version 3.1.2-p20 (2022-04-12) [x86_64-linux]
* Rails version 6.1.5.1
* Environment production
* Database adapter PostgreSQL
* Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/evmreports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ def create
# Save
if evm_report.save
# delete previus report of same status date
ProjectEvmreport.
where(project_id: evm_report.project_id, status_date: evm_report.status_date).
where.not(id: evm_report.id).delete_all
ProjectEvmreport.where(project_id: evm_report.project_id, status_date: evm_report.status_date).where.not(id: evm_report.id).delete_all
flash[:notice] = l(:notice_successful_create)
redirect_to action: :index
else
Expand Down
4 changes: 2 additions & 2 deletions app/views/common/_basic_evm_chart_js.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ var myChart = new Chart(ctx, {
intersect: false,
callbacks: {
title: function (tooltipItem, data){
var title = tooltipItem[0].xLabel;
return title.replace(", 12:00:00 am","");
var title = new Date(Date.parse(tooltipItem[0].xLabel));
return title.toDateString();
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/views/common/_option_field.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for :header_tags do %>
<%= stylesheet_link_tag "issue_evm", plugin: "redmine_issue_evm" %>
<%= javascript_include_tag "Chart.bundle.min.js" %>
<%= stylesheet_link_tag "issue_evm", plugin: "redmine_issue_evm" %>
<%= javascript_include_tag "Chart.bundle.min.js", plugin: "redmine_issue_evm" %>
<%= javascript_include_tag "chartjs-plugin-annotation.min.js", plugin: "redmine_issue_evm" %>
<% end %>
<script>
Expand Down
4 changes: 2 additions & 2 deletions app/views/evmassignees/_assignee_evm_chart_js.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ var myChart = new Chart(ctx, {
intersect: false,
callbacks: {
title: function (tooltipItem, data){
var title = tooltipItem[0].xLabel;
return title.replace(", 12:00:00 am","");
var title = new Date(Date.parse(tooltipItem[0].xLabel));
return title.toDateString();
}
}
},
Expand Down
10 changes: 5 additions & 5 deletions app/views/evms/_performance_chart_js.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ var myChart = new Chart(ctx, {
stacked: false,
gridLines: {
display: false
}
}
}],
yAxes: [{
gridLines: {
drawBorder: false
}
}]
}]
},
legend: {
display: true,
Expand All @@ -71,9 +71,9 @@ var myChart = new Chart(ctx, {
intersect: false,
callbacks: {
title: function (tooltipItem, data){
var title = tooltipItem[0].xLabel;
return title.replace(", 12:00:00 am","");
}
var title = new Date(Date.parse(tooltipItem[0].xLabel));
return title.toDateString();
}
}
},
annotation: {
Expand Down
4 changes: 2 additions & 2 deletions app/views/evms/_project_chart_js.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ var myChart = new Chart(ctx, {
intersect: false,
callbacks: {
title: function (tooltipItem, data){
var title = tooltipItem[0].xLabel;
return title.replace(", 12:00:00 am","");
var title = new Date(Date.parse(tooltipItem[0].xLabel));
return title.toDateString();
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions assets/javascripts/Chart.bundle.min.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions init.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ class RedmineIssueEvmHookListener < Redmine::Hook::ViewListener
end

# for search and activity page
Rails.configuration.to_prepare do
if Rails.version > "6.0" && Rails.autoloaders.zeitwerk_enabled?
Redmine::Activity.register "evmbaseline"
Redmine::Search.available_search_types << "evmbaselines"
else
Rails.configuration.to_prepare do
Redmine::Activity.register "evmbaseline"
Redmine::Search.available_search_types << "evmbaselines"
end
end

# module define
Redmine::Plugin.register :redmine_issue_evm do
name "Redmine Issue Evm plugin"
author "Hajime Nakagama"
description "Earned value management calculation plugin."
version "5.6.0"
version "6.0.0"
url "https://github.com/momibun926/redmine_issue_evm"
author_url "https://github.com/momibun926"
project_module :Issuevm do
Expand Down
57 changes: 0 additions & 57 deletions lib/base_calculate.rb

This file was deleted.

54 changes: 54 additions & 0 deletions lib/base_calculate_evm.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Calculation EVM base class.
# This class is base class of calculate AC, EV, PV(issues, baseline)
#
class BaseCalculateEvm
# Basis date
attr_reader :basis_date
# daily element
attr_reader :daily
# cumulative by date
attr_reader :cumulative

# Constractor
#
# @param [Date] basis_date basis date.
def initialize(basis_date)
# basis date
@basis_date = basis_date
end

# Cumulative ac at target date
#
# @param [Date] target_date pv at target date
# @return [Hash] cumulative at ac target date
def cumulative_at(target_date)
@cumulative.select { |k, _v| k <= target_date }
end

private

# Sort evm hash, Assending date.
#
# @param [Hash] evm_hash target issues of EVM
# @return [Hash] Sorted EVM hash. Key:date, Value:EVM value
def create_cumulative_evm(evm_hash)
temp_hash = {}
sum_value = 0.0
evm_hash.sort_by { |key, _val| key }.each do |date, value|
sum_value += value
temp_hash[date] = sum_value
end
temp_hash
end

# Add daily EVM value
#
# @param [Numeric] evm_value EVM value
# @param [Numeric] value EVM value
# @param [Numeric] done_ratio done ratio
# @return [Numeric] after add value
def add_daily_evm_value(evm_value, value, done_ratio = 100)
add_value = value.to_f * done_ratio.fdiv(100)
evm_value.nil? ? add_value : evm_value.to_f + add_value
end
end
69 changes: 32 additions & 37 deletions lib/calculate_ac.rb
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
require "base_calculate"
# Calculation AC class.
# AC calculate Spent time of pv issues.
#
class CalculateAc < BaseCalculateEvm
# min date of spent time (exclude basis date)
attr_reader :min_date
# max date of spent time (exclude basis date)
attr_reader :max_date

# Calculation EVM module
module CalculateEvmLogic
# Calculation AC class.
# AC calculate Spent time of pv issues.
# Constractor
#
class CalculateAc < BaseCalculateEvm
# min date of spent time (exclude basis date)
attr_reader :min_date
# max date of spent time (exclude basis date)
attr_reader :max_date

# Constractor
#
# @param [Date] basis_date basis date.
# @param [costs] costs culculation of AC.
def initialize(basis_date, costs)
super(basis_date)
# daily AC
@daily = costs.to_h
# minimum first date
# if no data, set basis date
@min_date = @daily.keys.min || @basis_date
# maximum last date
# if no data, set basis date
@max_date = @daily.keys.max || @basis_date
# basis date
@daily[@basis_date] ||= 0.0
# cumulative AC
@cumulative = create_cumulative_evm(@daily)
@cumulative.reject! { |k, _v| @basis_date < k }
end
# @param [Date] basis_date basis date.
# @param [costs] costs culculation of AC.
def initialize(basis_date, costs)
super(basis_date)
# daily AC
@daily = costs.to_h
# minimum first date
# if no data, set basis date
@min_date = @daily.keys.min || @basis_date
# maximum last date
# if no data, set basis date
@max_date = @daily.keys.max || @basis_date
# basis date
@daily[@basis_date] ||= 0.0
# cumulative AC
@cumulative = create_cumulative_evm(@daily)
@cumulative.reject! { |k, _v| @basis_date < k }
end

# Today's Actual cost
#
# @return [Numeric] AC on basis date
def today_value
@cumulative[@basis_date]
end
# Today's Actual cost
#
# @return [Numeric] AC on basis date
def today_value
@cumulative[@basis_date]
end
end
Loading

0 comments on commit 8e10a60

Please sign in to comment.