-
Notifications
You must be signed in to change notification settings - Fork 21
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
Update schools table #1318
Update schools table #1318
Conversation
We wanted to provide this data for the business analysts. The columns will be used for upcoming key info features.
We changed the update_school_data.rb to set the new information that we want based on the migration in the earlier commit. This information will be used by the business analysts for school-based metrics. We also want to surface some of this new information to job-seekers to help them make a decision.
@@ -0,0 +1,17 @@ | |||
class AddKeyInfoToSchools < ActiveRecord::Migration[5.2] | |||
def change | |||
add_column :schools, :status, :string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. These are a lot of columns to add at once. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's based on the columns needed for bigquery reporting and those needed for the key information tickets, wanted to avoid performing multiple migrations if possible 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I'm going to beat my usual drum on this one. Can you please put them in alphabetical order by the name of the column?
I have no issue with the number of them...
And be aware (mainly for @david-mears-dfe's benefit) - schema.rb will change as well.
@@ -29,6 +29,7 @@ def convert_to_school(row) | |||
school | |||
end | |||
|
|||
# rubocop:disable Metrics/AbcSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue but I think you can remove the need to disable this if you move all the new stuff into a separate method and call the method within set properties.
def set_properties(school, row)
school.name = row['EstablishmentName']
school.address = row['Street']
school.locality = row['Locality'].presence
school.address3 = row['Address3'].presence
school.town = row['Town']
school.county = row['County (name)'].presence
school.postcode = row['Postcode']
school.local_authority = row['LA (name)']
school.minimum_age = row['StatutoryLowAge']
school.maximum_age = row['StatutoryHighAge']
school.easting = row['Easting']
school.northing = row['Northing']
school.url = valid_website(row['SchoolWebsite'])
school.phase = row['PhaseOfEducation (code)'].to_i
set_school_key_info(school, row)
end
def set_school_key_info(school, row)
school.status = row['EstablishmentStatus (name)']
school.trust_name = row['Trusts (name)']
school.number_of_pupils = row['NumberOfPupils']
school.head_title = row['HeadTitle (name)']
school.head_first_name = row['HeadFirstName']
school.head_last_name = row['HeadLastName']
school.religious_character = row['ReligiousCharacter (name)']
school.rsc_region = row['RSCRegion (name)']
school.telephone = row['TelephoneNum']
school.open_date = row['OpenDate']
school.close_date = row['CloseDate']
school.last_ofsted_inspection_date = row['OfstedLastInsp']
school.oftsed_rating = row['OfstedRating (name)']
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all those columns are needed for the key info snippets, we decided to put it in one method based on export_vacancy_records_to_big_query.rb
and just disable to metric in order to keep it all in one place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These long lists of import attributes are difficult to read and maintain and fragile.
Can you please replace the hardcoded list of keys/attributes with an abstract method that maps keys of known format to symbols suitable for importing and have the migration follow the same schema. Please make the attribute names follow the names used by the API (so EstablishmentName
becomes school.establishment_name
- you can alias a school.name
public method to it to expose that for internal use).
@@ -119,6 +132,19 @@ | |||
expect(school.northing).to eql('181201') | |||
expect(school.geolocation.x).to be_within(0.0000000000001).of(51.51396894535262) | |||
expect(school.geolocation.y).to be_within(0.0000000000001).of(-0.07751626505544208) | |||
expect(school.status).to eql('Open') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these expectancies be refactored into a method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what kind of method did you have in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. Sorry for replying late @dushan-madetech
These lines of expectations are in two different tests, I think.
So I was wondering if there was a way to extract all the expectancies into a method and then call the method in the tests so that we could reduce the number of lines. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments. Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My two main issues are that long lists of individually-assigned attributes are fragile and a code smell. Please refactor so the attributes:
a) use the same name API attribute they are pulled from (at least as we store them, we can alias the stored version using public methods if we need a different name).
and
b) are alphabetised wherever we have to manually maintain that list.
@@ -0,0 +1,17 @@ | |||
class AddKeyInfoToSchools < ActiveRecord::Migration[5.2] | |||
def change | |||
add_column :schools, :status, :string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I'm going to beat my usual drum on this one. Can you please put them in alphabetical order by the name of the column?
I have no issue with the number of them...
And be aware (mainly for @david-mears-dfe's benefit) - schema.rb will change as well.
@@ -14,6 +14,19 @@ | |||
phase { :secondary } | |||
easting { '1' } | |||
northing { '1' } | |||
status { 'Open' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And again...sing with me now al-pha-bet-i-cal...
@@ -29,6 +29,7 @@ def convert_to_school(row) | |||
school | |||
end | |||
|
|||
# rubocop:disable Metrics/AbcSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These long lists of import attributes are difficult to read and maintain and fragile.
Can you please replace the hardcoded list of keys/attributes with an abstract method that maps keys of known format to symbols suitable for importing and have the migration follow the same schema. Please make the attribute names follow the names used by the API (so EstablishmentName
becomes school.establishment_name
- you can alias a school.name
public method to it to expose that for internal use).
Jira ticket URL:
https://dfedigital.atlassian.net/browse/TEVA-28
Changes in this PR: