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

College of Medicine - Effort rounding error #60

Merged
merged 2 commits into from
Dec 15, 2023
Merged
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
2 changes: 1 addition & 1 deletion app/importers/com_data/com_effort_populate_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def populate
faculty:)

com_effort.hours ||= 0
com_effort.hours += row['UME_CALCULATED_TEACHING_WHILE_NON_BILLING_EFFORT__HRS_'].to_f
com_effort.hours += row['UME_CALCULATED_TEACHING_WHILE_NON_BILLING_EFFORT__HRS_'].to_d

com_effort.save!
rescue ActiveRecord::RecordNotUnique
Expand Down
2 changes: 1 addition & 1 deletion app/importers/com_data/com_effort_xml_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def build_xml_effort(batch)
batch.each do |faculty|
xml.Record('PennStateHealthUsername' => faculty.com_id) do
faculty.com_efforts.each do |com_effort|
event_date = Date.strptime(com_effort.event_date, '%m/%d/%y')
event_date = Date.strptime(com_effort.event_date, '%m/%d/%Y')
xml.INSTRUCT_TAUGHT do
xml.COURSE_YEAR_ com_effort.course_year, access: 'READ_ONLY'
xml.COURSE_TITLE_ com_effort.course, access: 'READ_ONLY'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class ChangeHoursDataTypeInComEfforts < ActiveRecord::Migration[7.0]
def up
change_column :com_efforts, :hours, :decimal, precision: 10, scale: 2
end

def down
change_column :com_efforts, :hours, :integer
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
t.string "event_type"
t.string "faculty_name"
t.string "event"
t.integer "hours"
t.decimal "hours", precision: 10, scale: 2
t.bigint "faculty_id"
t.string "event_date"
t.index ["com_id", "course", "event", "event_date"], name: "index_com_efforts_on_com_id_and_course_and_event_and_event_date", unique: true, length: { course: 50, event: 50 }
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/ume_faculty_effort.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FACULTY_USERNAME,FACULTY_NAME,COURSE,COURSE_YEAR,EVENT_TYPE,EVENT,EVENT_DATE,UME_CALCULATED_TEACHING_WHILE_NON_BILLING_EFFORT__HRS_
lskywalker,Skywalker Luke,the Force,1976-1977,Lecture,FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid,5/25/77 10:00,2
hgranger,Granger Hermione,Potions,1997-1998,Sm Grp Facilitation,FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid,6/26/97 9:45,7
lskywalker,Skywalker Luke,the Force,1976-1977,Lecture,FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid,5/25/1977 10:00,2
hgranger,Granger Hermione,Potions,1997-1998,Sm Grp Facilitation,FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid,6/26/1997 9:45,7
10 changes: 5 additions & 5 deletions spec/importers/com_data/com_effort_populate_db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
arr_of_hashes = []
keys = headers
data_arr << ['lskywalker', 'Skywalker Luke', 'the Force', '1976-1977', 'Lecture',
'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid', '5/25/77 10:00', 2]
'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid', '5/25/1977 10:00', 2.5]
data_arr << ['lskywalker', 'Skywalker Luke', 'the Force', '1976-1977', 'Lecture',
'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid', '5/25/77 1:00', 4]
'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid', '5/25/1977 1:00', 4]
data_arr << ['hgranger', 'Granger Hermione', 'Potions', '1997-1998', 'Sm Grp Facilitation',
'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid', '6/26/97 9:45', 7]
'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid', '6/26/1997 9:45', 7]
data_arr << ['hgranger', 'Granger Hermione', 'Dark Arts', '2001-2002', 'Sm Grp Facilitation',
'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid', '11/1/01 12:00', 8]
'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid', '11/1/2001 12:00', 8]
data_arr.each { |a| arr_of_hashes << keys.zip(a).to_h }
arr_of_hashes
end
Expand Down Expand Up @@ -52,7 +52,7 @@
expect(ComEffort.find_by(com_id: 'hgranger').hours).to eq(8)
expect(ComEffort.find_by(com_id: 'hgranger').event_type).to eq('Sm Grp Facilitation')
expect(ComEffort.find_by(com_id: 'hgranger').event).to eq('FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid')
expect(ComEffort.find_by(com_id: 'lskywalker').hours).to eq(6)
expect(ComEffort.find_by(com_id: 'lskywalker').hours).to eq(6.5)
expect(ComEffort.find_by(com_id: 'lskywalker').event_type).to eq('Lecture')
expect(ComEffort.find_by(com_id: 'lskywalker').faculty).to eq(faculty2)
end
Expand Down
20 changes: 10 additions & 10 deletions spec/importers/com_data/com_effort_xml_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
'COURSE_YEAR' => '1976-1977',
'EVENT_TYPE' => 'Lecture',
'EVENT' => 'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid',
'EVENT_DATE' => '5/25/77',
'UME_CALCULATED_TEACHING_WHILE_NON_BILLING_EFFORT__HRS_' => 2 },
'EVENT_DATE' => '5/25/1977',
'UME_CALCULATED_TEACHING_WHILE_NON_BILLING_EFFORT__HRS_' => 2.5 },
{ 'FACULTY_USERNAME' => 'hgranger',
'FACULTY_NAME' => 'Granger Hermione',
'COURSE' => 'Potions',
'COURSE_YEAR' => '1997-1998',
'COURSE_YEAR' => '2022-2023',
'EVENT_TYPE' => 'Sm Grp Facilitation',
'EVENT' => 'FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid',
'EVENT_DATE' => '6/26/97',
'UME_CALCULATED_TEACHING_WHILE_NON_BILLING_EFFORT__HRS_' => 7 },
'EVENT_DATE' => '6/26/2023',
'UME_CALCULATED_TEACHING_WHILE_NON_BILLING_EFFORT__HRS_' => 7.25 },
{ 'FACULTY_USERNAME' => 'notCOM',
'FACULTY_NAME' => 'Not MD',
'COURSE' => 'test',
'COURSE_YEAR' => '2022-2023',
'EVENT_TYPE' => 'Lacture',
'EVENT' => 'Test Event for employee not in College of Medicine',
'EVENT_DATE' => '1/1/23',
'EVENT_DATE' => '1/1/2023',
'UME_CALCULATED_TEACHING_WHILE_NON_BILLING_EFFORT__HRS_' => 1 }]
end

Expand Down Expand Up @@ -61,19 +61,19 @@
<DTM_EVENT access="READ_ONLY">May</DTM_EVENT>
<DTD_EVENT access="READ_ONLY">25</DTD_EVENT>
<DTY_EVENT access="READ_ONLY">1977</DTY_EVENT>
<CAL_TEACH_HRS access="READ_ONLY">2</CAL_TEACH_HRS>
<CAL_TEACH_HRS access="READ_ONLY">2.5</CAL_TEACH_HRS>
</INSTRUCT_TAUGHT>
</Record>
<Record PennStateHealthUsername="hgranger">
<INSTRUCT_TAUGHT>
<COURSE_YEAR access="READ_ONLY">1997-1998</COURSE_YEAR>
<COURSE_YEAR access="READ_ONLY">2022-2023</COURSE_YEAR>
<COURSE_TITLE access="READ_ONLY">Potions</COURSE_TITLE>
<EVENT_TITLE access="READ_ONLY">FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid</EVENT_TITLE>
<EVENT_TYPE access="READ_ONLY">Sm Grp Facilitation</EVENT_TYPE>
<DTM_EVENT access="READ_ONLY">June</DTM_EVENT>
<DTD_EVENT access="READ_ONLY">26</DTD_EVENT>
<DTY_EVENT access="READ_ONLY">1997</DTY_EVENT>
<CAL_TEACH_HRS access="READ_ONLY">7</CAL_TEACH_HRS>
<DTY_EVENT access="READ_ONLY">2023</DTY_EVENT>
<CAL_TEACH_HRS access="READ_ONLY">7.25</CAL_TEACH_HRS>
</INSTRUCT_TAUGHT>
</Record>
</Data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def effort_body
"<EVENT_TITLE access=\"READ_ONLY\">FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid</EVENT_TITLE>\n " +
"<EVENT_TYPE access=\"READ_ONLY\">Sm Grp Facilitation</EVENT_TYPE>\n " +
"<DTM_EVENT access=\"READ_ONLY\">June</DTM_EVENT>\n <DTD_EVENT access=\"READ_ONLY\">26</DTD_EVENT>\n " +
"<DTY_EVENT access=\"READ_ONLY\">1997</DTY_EVENT>\n <CAL_TEACH_HRS access=\"READ_ONLY\">7</CAL_TEACH_HRS>\n " +
"<DTY_EVENT access=\"READ_ONLY\">1997</DTY_EVENT>\n <CAL_TEACH_HRS access=\"READ_ONLY\">7.0</CAL_TEACH_HRS>\n " +
"</INSTRUCT_TAUGHT>\n </Record>\n <Record PennStateHealthUsername=\"lskywalker\">\n <INSTRUCT_TAUGHT>\n " +
"<COURSE_YEAR access=\"READ_ONLY\">1976-1977</COURSE_YEAR>\n " +
"<COURSE_TITLE access=\"READ_ONLY\">the Force</COURSE_TITLE>\n " +
"<EVENT_TITLE access=\"READ_ONLY\">FTF REQ Various Rooms 10-12 PBL - EndoRepro PBL 1402 - Thyroid</EVENT_TITLE>\n " +
"<EVENT_TYPE access=\"READ_ONLY\">Lecture</EVENT_TYPE>\n <DTM_EVENT access=\"READ_ONLY\">May</DTM_EVENT>\n " +
"<DTD_EVENT access=\"READ_ONLY\">25</DTD_EVENT>\n <DTY_EVENT access=\"READ_ONLY\">1977</DTY_EVENT>\n " +
"<CAL_TEACH_HRS access=\"READ_ONLY\">2</CAL_TEACH_HRS>\n </INSTRUCT_TAUGHT>\n </Record>\n</Data>\n"
"<CAL_TEACH_HRS access=\"READ_ONLY\">2.0</CAL_TEACH_HRS>\n </INSTRUCT_TAUGHT>\n </Record>\n</Data>\n"
end

def error_message
Expand Down
2 changes: 1 addition & 1 deletion spec/models/com_effort_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
it { is_expected.to have_db_column(:faculty_name).of_type(:string) }
it { is_expected.to have_db_column(:event).of_type(:string) }
it { is_expected.to have_db_column(:event).of_type(:string) }
it { is_expected.to have_db_column(:hours).of_type(:integer) }
it { is_expected.to have_db_column(:hours).of_type(:decimal) }

it { is_expected.to have_db_index(%i[com_id course event event_date]).unique(true) }
it { is_expected.to have_db_index([:faculty_id]) }
Expand Down