Skip to content

Instantly share code, notes, and snippets.

View defong's full-sized avatar
🎯
Focusing

De Fong defong

🎯
Focusing
View GitHub Profile
@defong
defong / 2023-10-17.xml.rb
Last active November 1, 2023 11:55
[DfE] 6290-hertfordshire-uni-hesa-not-appearing-in-register
xml_response = Hesa::Client.get(url: "https://datacollection.hesa.ac.uk/apis/itt/1.1/CensusData/C23053/2023-10-26")
student_nodes = Nokogiri::XML::Reader(xml_response).filter_map do |node|
Nokogiri::XML(node.outer_xml).at("./Student") if node.name == "Student" && node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT
end
students = student_nodes.map do |student_node|
# student_attributes = Hash.from_xml(student_node.to_s)["Student"]
Hesa::Parsers::IttRecord.to_attributes(student_node:)
@defong
defong / 6057-itt-2022-3-husid-corrections-urgent.rb
Last active October 18, 2023 11:48
[DfE] 6057-itt-2022-3-husid-corrections-urgent.rb
corrections_required = [
["31009504/2/01","21100057900000137","2110750097246"],
["29002623/2/01","19100057900000123","1910750059931"],
["27034456/2/01","17100057900000163","1710750123984"],
["29020818/3/01","19100057900000536","1910750071885"],
["31021585/2/01","21100057900000023","2110750005355"],
["29024742/2/01","19100057900000570","1910750074015"],
["28012376/2/01","18100057900000148","1810750151559"],
["29005947/3/01","19100057900000824","1910750026715"],
["28016860/3/01","18100057900000182","1810750164696"],
@defong
defong / indexes---index_scan.psql
Last active October 13, 2023 08:30
[DfE] Register psql
-- NOTE: index scan indicator for busy table
SELECT
relname
, idx_scan
, last_idx_scan
FROM
pg_stat_user_tables
ORDER BY
idx_scan DESC
, relname ASC;
@defong
defong / 2299-rollover-courses-for-elluician.rb
Last active October 11, 2023 16:06
[DfE] 2299-rollover-courses-for-elluician
#############################
# NOTE: OPTION 2
# Not checked need to be checked
#############################
raise "no checked"
course = RecruitmentCycle.current.previous.providers.find_by(provider_code: "EEU").first
dupes = [["L050", course], "R301",course, "E293", course, "K596", course]
@defong
defong / 2293-reinstate-withdrawn-course.rb
Last active October 10, 2023 15:04
[DfE] 2293-reinstate-withdrawn-course
Please could Computing (3379) at Carmel College (1KF) have its withdrawal reverted
course = RecruitmentCycle.current.providers.find_by(provider_code: "1KF").courses.find_by(course_code: "3379")
course.enrichments.max_by(&:created_at).update(status: "published", last_published_timestamp_utc: Time.now.utc)
course.site_statuses.each do |site_status|
site_status.update(vac_status: :no_vacancies, status: :running)
end
@defong
defong / 2292-copy-courses-to-new-providers.rb
Last active October 10, 2023 14:32
[DfE] 2292-copy-courses-to-new-providers
copier = Courses::CopyToProviderService.new(sites_copy_to_course: Sites::CopyToCourseService, enrichments_copy_to_course: Enrichments::CopyToCourseService.new, force: true)
[
["1KN", "4B5"],
["1KY", "5B3"],
["1BK", "3M1"],
["2CC", "2O2"],
["1CU", "3V2"],
].each do |source, target|
@defong
defong / 2290-student-visa.rb
Last active October 10, 2023 10:32
[DfE] 2290-student-visa
# https://www.publish-teacher-training-courses.service.gov.uk/publish/organisations/1A8/2024/courses/372X
# https://www.publish-teacher-training-courses.service.gov.uk/publish/organisations/1A8/2024/courses/3735
#
# to no
courses = RecruitmentCycle.current.providers.find_by(provider_code: "1A8").courses.where(course_code: ["372X", "3735" ] )
courses.update!(can_sponsor_student_visa: false)
@defong
defong / 2289-visa-sponsorship.rb
Last active October 10, 2023 10:26
[DfE] 2289-visa-sponsorship
# https://www.publish-teacher-training-courses.service.gov.uk/publish/organisations/2JJ/2024/courses
#
# Change to yes
courses = RecruitmentCycle.current.providers.find_by(provider_code: "2JJ").courses
courses.update!(can_sponsor_student_visa: true)
@defong
defong / 2274-ellucian-sandbox-course-issue.rb
Last active October 5, 2023 11:04
[DfE] 2274-ellucian-sandbox-course-issue
#### Before state
run_me = false
(Provider.find_by(code: "EEU")) if run_me
#<Provider:0x00007fe5328a0768 id: 2619, name: "University of Ellucian", code: "EEU", created_at: Wed, 24 Feb 2021 12:23:48.431310000 GMT +00:00, updated_at: Mon, 20 Feb 2023 05:50:44.486124000 GMT +00:00, region_code: nil, postcode: "", provider_type: "university", latitude: nil, longitude: nil, vendor_id: nil>
# Supect rogue cache
# https://github.com/DFE-Digital/apply-for-teacher-training/blob/main/app/controllers/candidate_interface/course_choices/provider_selection_controller.rb#L8
# https://github.com/DFE-Digital/apply-for-teacher-training/blob/main/app/forms/candidate_interface/continuous_applications/provider_selection_step.rb#L12
(@provider_cache_key ||= "provider-list-#{Provider.maximum(:updated_at)}") if run_me
@defong
defong / 2272-update-visa-sponsorship-section.rb
Last active October 4, 2023 15:56
[DfE] 2272-update-visa-sponsorship-section
courses = RecruitmentCycle.current.providers.find_by(provider_code: "1KN").courses.where(course_code: ["3857", "H430", "3853", "384T", "384G", "38KK",])
courses.update!(can_sponsor_student_visa: false)