Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Semester Column to Engagements #53

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/models/engagement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,19 @@ def summarize_customer_rating
cum.merge(cur) {|_key, oldValue, newValue| oldValue + newValue / valid_count.to_f}
end
end

def get_semester
# For simplicity, chose (1/1-5/15) as spring sem, (5/16-8/15) as summer sem, (8/16-12/31) as fall sem
sp_end = DateTime.new(start_date.year, 5, 16)
su_end = DateTime.new(start_date.year, 8, 16)

if start_date < sp_end
sem = "SP"
elsif start_date < su_end
sem = "SU"
else
sem = "FA"
end
start_date.strftime("#{sem}%y")
end
end
2 changes: 2 additions & 0 deletions app/views/engagements/_index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
%table.table
%thead
%tr
%th Semester
%th Started
%th Contact
%th Coach
Expand All @@ -14,6 +15,7 @@
- engagements.each do |engagement|
- app = engagement.app
%tr
%td= engagement.get_semester()
%td= link_to engagement.start_date.strftime('%F'), engagement_iterations_path(engagement)
%td= mail_to(engagement.client.email, engagement.client.name) if engagement.client
%td{style: 'max-width: 150px; overflow: hidden;'}= [engagement.coach.try(:name),engagement.coaching_org.try(:name)].join(', ')
Expand Down
47 changes: 47 additions & 0 deletions features/engagement_sem.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Feature: Adding "semester" field for start date record
As an authorized user
So that I can check the project details
I want to see the start semester of some projects

Background: Logged in
Given the following apps exist:
| name | description | org_id | status |
| app1 | test | 1 | pending |
| app2 | test | 1 | pending |
| app3 | test | 1 | pending |

And the following engagements exist:
| id | app_id | coach_id | team_number | start_date | student_names | features |
| 1 | 1 | 1 | 1 | 2017-10-01 | fake1, fake2, fake3 | Adding feature boxes |
| 2 | 1 | 1 | 1 | 2018-04-28 | fake1, fake2, fake3 | Adding feature boxes |
| 3 | 1 | 1 | 1 | 2018-06-12 | fake1, fake2, fake3 | Adding feature boxes |

And the following iterations exist:
| id | engagement_id | end_date | customer_feedback |
| 1 | 1 | 2017-10-26 | |

And the following orgs exist:
| name | contact_id |
| org1 | 1 |
| org2 | 1 |
| org3 | 1 |

And the following users exist:
| id | name | github_uid | email | user_type |
| 1 | user1 | esaas_developer | [email protected] | coach |
| 2 | user2 | | [email protected] | student |
| 3 | user3 | | [email protected] | client |
| 4 | user4 | | [email protected] | client |


And I'm logged in on the orgs page
And I follow "Apps"

# Story ID: 176932021
Scenario: A user can see the semester for each iteration on App's detail page
Given I follow "app1"
Then I should see "Semester"
And I should see "FA17"
And I should see "SP18"
And I should see "SU18"

36 changes: 36 additions & 0 deletions spec/models/engagement_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'rails_helper'
require 'byebug'

describe Engagement do
#Story ID: #153069725
Expand Down Expand Up @@ -86,5 +87,40 @@

end

# Story ID: 176932021
describe 'convert start date to semester' do
it 'converts semesters' do
eng = Engagement.new

eng.start_date = DateTime.new(2017,2,3)
expect(eng.get_semester()).to eq('SP17')

eng.start_date = DateTime.new(2018,6,7)
expect(eng.get_semester()).to eq('SU18')

eng.start_date = DateTime.new(2019,9,10)
expect(eng.get_semester()).to eq('FA19')

# This needs an extra 8 because 8 hours gets subtracted from the datetime, unsure why
eng.start_date = DateTime.new(2017,1,1,8)
expect(eng.get_semester()).to eq('SP17')

eng.start_date = DateTime.new(2017,5,15)
expect(eng.get_semester()).to eq('SP17')

eng.start_date = DateTime.new(2017,8,15)
expect(eng.get_semester()).to eq('SU17')

eng.start_date = DateTime.new(2017,8,16)
expect(eng.get_semester()).to eq('FA17')

eng.start_date = DateTime.new(2017,12,31,8)
expect(eng.get_semester()).to eq('FA17')

eng.start_date += 1.days
expect(eng.get_semester()).to eq('SP18')
end

end

end