Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed year resolution; added screenshot; some bugs corrected;

  • Loading branch information...
commit 090c5ddc2420437ece29b3e6d3bd5767abfaf075 1 parent c80cbe1
@JoaoCostaImag JoaoCostaImag authored
View
81 .gitignore
@@ -1,56 +1,29 @@
-# Compiled source #
-###################
-*.com
-*.class
-*.dll
-*.exe
-*.o
-*.so
-
-# Packages #
-############
-# it's better to unpack these files and commit the raw source
-# git has its own built in compression methods
-*.7z
-*.dmg
-*.gz
-*.iso
-*.jar
-*.rar
-*.tar
-*.zip
-
-# Logs and databases #
-######################
-*.log
-*.sql
-*.sqlite
-
-# OS generated files #
-######################
-.DS_Store
-.DS_Store?
-._*
-.Spotlight-V100
-.Trashes
-Icon?
-ehthumbs.db
-Thumbs.db
-*.*~
-
+/.project
+/.loadpath
+/config/additional_environment.rb
+/config/email.yml
+/config/initializers/session_store.rb
+/coverage
+/db/*.db
+/db/*.sqlite3
+/db/schema.rb
+/files/*
+/lib/redmine/scm/adapters/mercurial/redminehelper.pyc
+/lib/redmine/scm/adapters/mercurial/redminehelper.pyo
+/log/*.log*
+/log/mongrel_debug
+/public/dispatch.*
+/public/plugin_assets
+/tmp/*
+/tmp/cache/*
+/tmp/sessions/*
+/tmp/sockets/*
+/tmp/test/*
+/vendor/cache
+/vendor/rails
*.rbc
-*.sassc
-.sass-cache
-capybara-*.html
-.rspec
+
/.bundle
-/vendor/bundle
-/log/*
-/tmp/*
-/db/*.sqlite3
-/public/system/*
-/coverage/
-/spec/tmp/*
-**.orig
-rerun.txt
-pickle-email-*.html
+/Gemfile.local
+/.idea/*
+.svn
View
4 init.rb
@@ -7,7 +7,9 @@
url 'http://imaginarycloud.com'
author_url 'mailto:jcosta@imaginarycloud.com'
- permission :ratios, { :ratios => [:index] }, :public => true
+ project_module :ratios do
+ permission :ratios, { :ratios => [:index] }, :public => true
+ end
menu :project_menu, :ratios, { :controller => 'ratios', :action => 'index' }, :caption => 'EVM', :after => :files
View
14 init.rb~
@@ -0,0 +1,14 @@
+Redmine::Plugin.register :redmine_evm do
+
+ name 'Redmine Evm plugin'
+ author 'ImaginaryCloud'
+ description 'Graphical indicators for EV Management'
+ version '0.9.0'
+ url 'http://imaginarycloud.com'
+ author_url 'mailto:jcosta@imaginarycloud.com'
+
+ permission :ratios, { :ratios => [:index] }, :public => true
+ menu :project_menu, :ratios, { :controller => 'ratios', :action => 'index' }, :caption => 'EVM', :after => :files
+
+
+end
View
17 lib/indicators_logic.rb
@@ -13,6 +13,7 @@ def self.retrive_data(project_or_version)
ary_reported_time_week_year = my_project.time_entries.sum(:hours, :group =>[:tweek, :tyear], :order=> [:tyear, :tweek])
ary_all_issues = my_project.issues
end
+
return [ary_reported_time_week_year, ary_all_issues]
end
@@ -26,31 +27,31 @@ def self.calc_indicators(my_project_or_version, ary_reported_time_week_year, ary
ary_weeks_years = []
- real_start_date = my_project_or_version.start_date.nil? ? (Time.now.to_date - 1.day): my_project_or_version.start_date.beginning_of_week
+ real_start_date = [(my_project_or_version.start_date.nil? ? (Time.now.to_date - 1.day): my_project_or_version.start_date.beginning_of_week), (ary_reported_time_week_year.empty? ? Time.now.to_date : Date.ordinal(ary_reported_time_week_year.keys.first[1], ary_reported_time_week_year.keys.first[0]*7-3))].min
+
while real_start_date < my_project_or_version_end_date + 1.week
- ary_weeks_years << [real_start_date.cweek, real_start_date.year]
+ ary_weeks_years << [real_start_date.cweek, real_start_date.cwyear]
real_start_date += 1.week
end
-
+
hash_weeks_years = {}
ary_weeks_years.each{|e| hash_weeks_years[e] = [0,0,0]}
@done_ratio = 0
-
+
ary_all_issues.each do |issue|
start_issue_date = issue.start_date? ? issue.start_date : my_project_or_version.start_date
end_issue_date = issue.due_date? ? issue.due_date : my_project_or_version_end_date
estimated_time = issue.estimated_hours? ? issue.estimated_hours : 0
- @done_ratio = (issue.done_ratio / 100)
+ @done_ratio = (issue.done_ratio / 100.0)
ary_dates = (start_issue_date..end_issue_date).to_a
ary_dates.delete_if{|x| x.saturday? || x.sunday?}
if ary_dates.any? && estimated_time != 0
- hoursPerDay = estimated_time / ary_dates.size
-
+ hoursPerDay = estimated_time / ary_dates.size
ary_dates.each do |day|
week = day.cweek
- year = day.year
+ year = day.cwyear
hash_weeks_years[[week,year]][1] += hoursPerDay
hash_weeks_years[[week,year]][2] += hoursPerDay * @done_ratio
end
View
101 lib/indicators_logic.rb~
@@ -0,0 +1,101 @@
+module IndicatorsLogic
+
+ def self.retrive_data(project_or_version)
+ if project_or_version.instance_of? Version
+ my_project = project_or_version.project
+ my_version = project_or_version
+
+ ary_reported_time_week_year = my_project.time_entries.where(:issue_id=>Issue.where(:fixed_version_id=>my_version.id)).sum(:hours, :group =>[:tweek, :tyear], :order=> [:tyear, :tweek])
+ ary_all_issues = my_version.fixed_issues
+
+ else
+ my_project = project_or_version
+ ary_reported_time_week_year = my_project.time_entries.sum(:hours, :group =>[:tweek, :tyear], :order=> [:tyear, :tweek])
+ ary_all_issues = my_project.issues
+ end
+ #ary_reported_time_week_year is ACTUAL COST
+ Rails.logger.info "Este e o array com values do entity: #{ary_reported_time_week_year}"
+ return [ary_reported_time_week_year, ary_all_issues]
+ end
+
+
+ def self.calc_indicators(my_project_or_version, ary_reported_time_week_year, ary_all_issues)
+
+ #This part will determine first and last date in entity
+ check_end_date = my_project_or_version.due_date || Time.now.to_date
+ check_ary_reported_time_week_year = ary_reported_time_week_year.empty? ? Time.now.to_date : Date.ordinal(ary_reported_time_week_year.keys.last[1], ary_reported_time_week_year.keys.last[0]*7-3)
+ check_ary_all_issues = ary_all_issues.empty? ? Time.now.to_date : ary_all_issues.maximum(:start_date)
+ my_project_or_version_end_date = [check_end_date,check_ary_reported_time_week_year, check_ary_all_issues].max
+
+ ary_weeks_years = []
+
+ #This will generate a array with weeks and years from initial entity date to entity last date known
+ #It will serve as keys for hash containing values
+ #!!!!! ATTENTION - TIME ENTRIES BEFORE START DATE AREN'T CONSIDERED - MUST CHANGE THAT!!!!
+ real_start_date = [(my_project_or_version.start_date.nil? ? (Time.now.to_date - 1.day): my_project_or_version.start_date.beginning_of_week), (ary_reported_time_week_year.empty? ? Time.now.to_date : Date.ordinal(ary_reported_time_week_year.keys.first[1], ary_reported_time_week_year.keys.first[0]*7-3))].min
+ #real_start_date = my_project_or_version.start_date.nil? ? (Time.now.to_date - 1.day): my_project_or_version.start_date.beginning_of_week
+ Rails.logger.info "Este e a start date : #{real_start_date.to_s}"
+ while real_start_date < my_project_or_version_end_date + 1.week
+ ary_weeks_years << [real_start_date.cweek, real_start_date.cwyear]
+ real_start_date += 1.week
+ end
+
+ Rails.logger.info "Este e o array das dates : #{ary_weeks_years}"
+ hash_weeks_years = {}
+ ary_weeks_years.each{|e| hash_weeks_years[e] = [0,0,0]}
+ @done_ratio = 0
+
+ #This will iterate from all issues to retrieve data
+ ary_all_issues.each do |issue|
+
+ start_issue_date = issue.start_date? ? issue.start_date : my_project_or_version.start_date
+ end_issue_date = issue.due_date? ? issue.due_date : my_project_or_version_end_date
+ estimated_time = issue.estimated_hours? ? issue.estimated_hours : 0
+ @done_ratio = (issue.done_ratio / 100.0)
+ ary_dates = (start_issue_date..end_issue_date).to_a
+ ary_dates.delete_if{|x| x.saturday? || x.sunday?}
+
+ if ary_dates.any? && estimated_time != 0
+ hoursPerDay = estimated_time / ary_dates.size
+ ary_dates.each do |day|
+ week = day.cweek
+ year = day.cwyear
+ hash_weeks_years[[week,year]][1] += hoursPerDay
+ hash_weeks_years[[week,year]][2] += hoursPerDay * @done_ratio
+ end
+
+ end
+
+ end
+
+ @ary_data_week_years = [Array['week', 'ActualCost', 'PlannedCost', 'EarnedValue']]
+ sum_real = 0
+ sum_planned = 0
+ sum_earned = 0
+
+ hash_weeks_years.each do |k,v|
+ #This is actual cost per week
+ sum_real += ary_reported_time_week_year.has_key?(k)? ary_reported_time_week_year[k] : 0
+ v[0] = sum_real
+ #This is budget cost per week
+ sum_planned += v[1]
+ v[1] = sum_planned
+ sum_earned += v[2]
+ v[2] = sum_earned
+ @ary_data_week_years.push(Array[k[0].to_s + "/" + k[1].to_s, v[0].round(2), v[1].round(2), v[2].round(2)])
+ end
+
+ @cpi = hash_weeks_years.values.last[0].zero? ? 0 : hash_weeks_years.values.last[2]/hash_weeks_years.values.last[0]
+ @spi = hash_weeks_years.values.last[1].zero? ? 0 : hash_weeks_years.values.last[2]/hash_weeks_years.values.last[1]
+ Rails.logger.info "Este e o array com values do calc: #{@ary_data_week_years}"
+ return [@ary_data_week_years, @cpi, @spi]
+
+ end
+
+
+
+ def self.included(base)
+ base.send :helper_method, :calc_indicators, :retrive_data if base.respond_to? :helper_method
+ end
+
+end
View
BIN  screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.