Skip to content

Commit

Permalink
Merge branch 'master' into feature/project-delete-confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
kostadriano committed Oct 17, 2018
2 parents 60fb7ac + 486f3b7 commit 4bee0ba
Show file tree
Hide file tree
Showing 15 changed files with 247 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
- Option to archive teams
- Added pusher-fake to the project
- Project delete confirmation
- Field velocity_strategy to projects

### Fixed
- Fixed locale change when accessing user edit page
- Fixed Project delete
- Fixed `story-description` and `.note` by adding to sortable column canceled elements/nodes
- Fix calculation of first sprint size


### Changed
Expand Down
1 change: 1 addition & 0 deletions app/api/entities/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Entities::Project < Entities::BaseEntity
expose :iteration_start_day
expose :iteration_length
expose :default_velocity
expose :velocity_strategy
expose :velocity, if: { type: :full }
expose :volatility, if: { type: :full }
expose :teams, using: Entities::Team
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def allowed_params
.fetch(:project)
.permit(:name, :point_scale, :default_velocity, :tag_group_id, :start_date,
:iteration_start_day, :iteration_length, :import, :archived,
:disallow_join, :mail_reports)
:disallow_join, :mail_reports, :velocity_strategy)
end

def fluid_layout
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/projects_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,12 @@ def formatted_standard_deviation(standard_deviation)
def inverse_story_flow
'pressed' if @story_flow[:current].eql?(@story_flow[:default])
end

# Returns an array of valid velocity strategy options suitable for use in
# a select helper.
def velocity_strategy_options
(1..4).collect do |iterations|
[I18n.t('n velocity strategy', count: iterations), iterations]
end
end
end
43 changes: 26 additions & 17 deletions app/models/iterations/project_iterations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ def initialize(project:)
end

def current_iteration_start
project_start_date + (length * iteration_length_in_days)
first_iteration_expected_start_date + (number_of_iterations * iteration_length_in_days)
end

def past_iterations
(0...length).map do |iteration_number|
start_at = start_date(iteration_number)
end_at = end_date(start_at)
start_at = project.start_date
end_at = iteration_end_date(first_iteration_expected_start_date)

(0...number_of_iterations).map do |iteration_number|
if iteration_number != 0
start_at = iteration_start_date(iteration_number)
end_at = iteration_end_date(start_at)
end

PastIteration.new(
start_date: start_at,
Expand Down Expand Up @@ -45,29 +50,33 @@ def stories
end
end

def length
(days_since_project_start / iteration_length_in_days).floor
def missing_days_from_first_sprint
(project.start_date.wday - project.iteration_start_day) % DAYS_IN_A_WEEK
end

def iteration_length_in_days
project.iteration_length * DAYS_IN_A_WEEK
def first_iteration_expected_start_date
project.start_date - missing_days_from_first_sprint
end

def project_start_date
project.start_date
def number_of_iterations
(days_since_first_iteration_start / iteration_length_in_days).floor
end

def iteration_length_in_days
project.iteration_length * DAYS_IN_A_WEEK
end

def start_date(iteration_number)
iteration_days = (iteration_number * iteration_length_in_days)
(project_start_date + iteration_days)
def iteration_start_date(iteration_number)
iteration_days = iteration_number * iteration_length_in_days
first_iteration_expected_start_date + iteration_days
end

def end_date(start_date)
(start_date + (iteration_length_in_days - 1))
def iteration_end_date(start_date)
start_date + (iteration_length_in_days - 1)
end

def days_since_project_start
Date.current - project_start_date
def days_since_first_iteration_start
Date.current - first_iteration_expected_start_date
end
end
end
11 changes: 10 additions & 1 deletion app/views/projects/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
<%= f.text_field :default_velocity, length: 2, size: 3, class: 'form-control auth-form-control' %>
</div>

<div class="form-group">
<%= f.label :velocity_strategy %>
<%= f.select :velocity_strategy,
velocity_strategy_options,
{},
{ class:'form-control auth-form-control' }
%>
</div>

<div class="form-group date-form-group">
<%= f.label :start_date, class: 'control-label' %> <br>
<%= f.date_select :start_date, {}, { class: 'form-control auth-form-control' } %>
Expand Down Expand Up @@ -52,7 +61,7 @@
<%= f.label :mail_reports, class: 'control-label' %>
<%= f.check_box :mail_reports %>
</div>

<div class="btn-group actions pull-right clearfix">
<%= f.submit nil, class: 'btn btn-primary btn-form' %>
Expand Down
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ en:
one: '1 week'
other: '%{count} weeks'

n velocity strategy:
one: 'Average of 1 iteration'
other: 'Average of %{count} iterations'

keycuts:
keyboard_shortcuts: Keyboard shortcuts
help: Help (this)
Expand Down Expand Up @@ -178,6 +182,7 @@ en:
default_velocity: 'Default velocity'
archived: 'Archived'
mail_reports: 'Send reports via mail'
velocity_strategy: 'Velocity strategy'
story:
title: 'Title'
description: 'Description'
Expand Down
5 changes: 5 additions & 0 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ pt-BR:
one: '1 semana'
other: '%{count} semanas'

n velocity strategy:
one: 'Média de 1 iteração'
other: 'Média de %{count} iterações'

keycuts:
keyboard_shortcuts: Atalhos de teclado
help: Ajuda (this)
Expand Down Expand Up @@ -175,6 +179,7 @@ pt-BR:
default_velocity: 'Velocidade padrão'
archived: 'Arquivado'
mail_reports: 'Enviar relatórios por email'
velocity_strategy: 'Estratégia de velocidade'
story:
title: 'Título'
description: 'Descrição'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddVelocityStrategyToProjects < ActiveRecord::Migration
def change
add_column :projects, :velocity_strategy, :integer, default: 3
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170914172941) do
ActiveRecord::Schema.define(version: 20180823124914) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -170,6 +170,7 @@
t.boolean "disallow_join", default: true, null: false
t.integer "tag_group_id"
t.boolean "mail_reports", default: true
t.integer "velocity_strategy", default: 3
end

add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree
Expand Down
6 changes: 6 additions & 0 deletions spec/api/entities/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
it { expect(subject[:volatility]).to be_nil }
it { expect(subject[:mail_reports]).to be_truthy }

it do
expect(
subject[:velocity_strategy]
).to eq(project.velocity_strategy)
end

context 'when call it with full type' do
subject { described_class.represent(project, type: :full).as_json }

Expand Down
4 changes: 3 additions & 1 deletion spec/factories/project_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
trait :with_past_iteration do
created_at { Time.current.days_ago(10) }
start_date { Time.current.days_ago(10) }
iteration_start_day { Time.current.days_ago(10).wday }
end

trait :with_month_ago do
trait :created_one_month_ago do
created_at { Time.current.months_ago(1) }
start_date { Time.current.months_ago(1) }
iteration_start_day { Time.current.months_ago(1).wday }
end
end
12 changes: 12 additions & 0 deletions spec/helpers/projects_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,16 @@
end
end
end

describe '#velocity_strategy_options' do
subject(:options) { helper.velocity_strategy_options }

it 'returns an array containing translated options to use in a select' do
(1..4).each do |iteration|
expect(options).to include(
[I18n.t('n velocity strategy', count: iteration), iteration]
)
end
end
end
end

0 comments on commit 4bee0ba

Please sign in to comment.