Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ spec/examples.txt
.envrc
.irb_history
.DS_Store
CLAUDE.md
CLAUDE.md
/docs/superpowers/
27 changes: 19 additions & 8 deletions app/importers/committee_data/committee_xml_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@ def build_xml(batch)
xml.Record(username: faculty.access_id) do
committees.each do |committee|
xml.DSL do
xml.ROLE committee.role
xml.TYPE committee.type_of_work
xml.COMPSTAGE committee.stage_of_completion
xml.DTY_START committee.start_year
xml.DTY_END committee.completion_year if committee.completion_year
xml.ROLE committee.role, access: 'READ_ONLY'
xml.ROLE_OTHER committee.role_other, access: 'READ_ONLY' if committee.role_other.present?
xml.TYPE committee.type_of_work, access: 'READ_ONLY'
xml.COMPSTAGE committee.stage_of_completion, access: 'READ_ONLY'

same_date = committee.start_year == committee.completion_year &&
committee.start_month == committee.completion_month

unless same_date
xml.DTM_START Date::MONTHNAMES[committee.start_month], access: 'READ_ONLY' if committee.start_month
xml.DTY_START committee.start_year, access: 'READ_ONLY' if committee.start_year
end

xml.DTM_END Date::MONTHNAMES[committee.completion_month], access: 'READ_ONLY' if committee.completion_month
xml.DTY_END committee.completion_year, access: 'READ_ONLY' if committee.completion_year

xml.DSL_STUDENT do
xml.FNAME committee.student_fname
xml.LNAME committee.student_lname
xml.TITLE committee.thesis_title
xml.FNAME committee.student_fname, access: 'READ_ONLY'
xml.LNAME committee.student_lname, access: 'READ_ONLY'
xml.DEG committee.degree_name, access: 'READ_ONLY' if committee.degree_name.present?
xml.TITLE committee.thesis_title, access: 'READ_ONLY'
end
end
end
Expand Down
18 changes: 15 additions & 3 deletions app/importers/committee_data/etda_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ def import_for_faculty(faculty)
committees_data.each do |committee|
next unless within_last_six_months?(committee['approval_started_at'])

normalized_role = CommitteeRoleNormalizer.normalize(committee['role'])
role, role_other = CommitteeRoleNormalizer.normalize(committee['role'])

faculty.committees.create!(
student_fname: committee['student_fname'],
student_lname: committee['student_lname'],
role: normalized_role,
role: role,
role_other: role_other,
thesis_title: committee['title'],
type_of_work: map_type_of_work(committee['degree_type']),
degree_name: committee['degree_name'],
stage_of_completion: determine_completion_stage(
committee['final_submission_approved_at']
),
start_year: extract_year(committee['approval_started_at']),
completion_year: extract_year(committee['final_submission_approved_at'])
start_month: extract_month(committee['approval_started_at']),
completion_year: extract_year(committee['final_submission_approved_at']),
completion_month: extract_month(committee['final_submission_approved_at'])
)
end

Expand Down Expand Up @@ -66,6 +70,14 @@ def extract_year(date_string)
nil
end

def extract_month(date_string)
return nil if date_string.blank?

Date.parse(date_string).month
rescue ArgumentError
nil
end

def within_last_six_months?(date_string)
return false if date_string.blank?

Expand Down
6 changes: 3 additions & 3 deletions app/services/committee_role_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class CommitteeRoleNormalizer

def self.normalize(raw_name)
text = raw_name.to_s.strip
return 'Other' if text.empty?
return ['Other', nil] if text.empty?

PRIORITY_REGEX.each do |label, regex|
return label if text.match?(regex)
return [label, nil] if text.match?(regex)
end

'Other'
['Other', text]
end
end
8 changes: 8 additions & 0 deletions db/migrate/20260423000000_add_months_to_committees.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class AddMonthsToCommittees < ActiveRecord::Migration[7.2]
def change
change_table :committees, bulk: true do |t|
t.integer :start_month
t.integer :completion_month
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20260428000000_add_role_other_to_committees.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddRoleOtherToCommittees < ActiveRecord::Migration[7.2]
def change
add_column :committees, :role_other, :string
end
end
5 changes: 5 additions & 0 deletions db/migrate/20260428120000_add_degree_name_to_committees.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDegreeNameToCommittees < ActiveRecord::Migration[7.2]
def change
add_column :committees, :degree_name, :string
end
end
48 changes: 26 additions & 22 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2026_03_26_000000) do
create_table "authors", charset: "utf8mb4", force: :cascade do |t|
ActiveRecord::Schema[7.2].define(version: 2026_04_28_120000) do
create_table "authors", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "f_name"
t.string "m_name"
t.string "l_name"
t.bigint "work_id"
t.index ["work_id"], name: "fk_rails_ef7807179c"
end

create_table "com_efforts", charset: "utf8mb4", force: :cascade do |t|
create_table "com_efforts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "com_id"
Expand All @@ -35,7 +35,7 @@
t.index ["faculty_id"], name: "fk_rails_c1c0816923"
end

create_table "com_qualities", charset: "utf8mb4", force: :cascade do |t|
create_table "com_qualities", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "com_id"
Expand All @@ -51,7 +51,7 @@
t.index ["faculty_id"], name: "fk_rails_5da34f5b2e"
end

create_table "committees", charset: "utf8mb4", force: :cascade do |t|
create_table "committees", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "faculty_id", null: false
t.string "student_fname"
t.string "student_mname"
Expand All @@ -64,10 +64,14 @@
t.string "stage_of_completion"
t.integer "start_year"
t.integer "completion_year"
t.integer "start_month"
t.integer "completion_month"
t.string "role_other"
t.string "degree_name"
t.index ["faculty_id"], name: "index_committees_on_faculty_id"
end

create_table "contract_faculty_links", charset: "utf8mb4", force: :cascade do |t|
create_table "contract_faculty_links", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "role"
t.integer "pct_credit"
t.bigint "contract_id"
Expand All @@ -76,7 +80,7 @@
t.index ["faculty_id"], name: "fk_rails_7f7c136a9d"
end

create_table "contracts", charset: "utf8mb4", force: :cascade do |t|
create_table "contracts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.integer "osp_key"
t.string "title"
t.bigint "sponsor_id"
Expand All @@ -98,7 +102,7 @@
t.index ["sponsor_id"], name: "fk_rails_918599a14c"
end

create_table "courses", charset: "utf8mb4", force: :cascade do |t|
create_table "courses", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.integer "academic_course_id"
t.string "term"
t.integer "calendar_year"
Expand All @@ -107,15 +111,15 @@
t.index ["academic_course_id", "term", "calendar_year"], name: "index_courses_on_academic_course_id_and_term_and_calendar_year", unique: true
end

create_table "editors", charset: "utf8mb4", force: :cascade do |t|
create_table "editors", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "f_name"
t.string "m_name"
t.string "l_name"
t.bigint "work_id"
t.index ["work_id"], name: "fk_rails_6c877ed7df"
end

create_table "external_authors", charset: "utf8mb4", force: :cascade do |t|
create_table "external_authors", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "publication_id"
t.string "f_name"
t.string "m_name"
Expand All @@ -127,7 +131,7 @@
t.index ["publication_id"], name: "fk_rails_eb03e1acd5"
end

create_table "faculties", charset: "utf8mb4", force: :cascade do |t|
create_table "faculties", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "access_id"
t.bigint "user_id"
t.string "f_name"
Expand All @@ -141,14 +145,14 @@
t.index ["access_id"], name: "index_faculties_on_access_id", unique: true
end

create_table "integrations", charset: "utf8mb4", force: :cascade do |t|
create_table "integrations", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "process_type"
t.boolean "is_active"
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
end

create_table "personal_contacts", charset: "utf8mb4", force: :cascade do |t|
create_table "personal_contacts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "faculty_id", null: false
t.string "telephone_number"
t.string "postal_address"
Expand All @@ -167,15 +171,15 @@
t.index ["faculty_id"], name: "index_personal_contacts_on_faculty_id", unique: true
end

create_table "presentation_contributors", charset: "utf8mb4", force: :cascade do |t|
create_table "presentation_contributors", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "presentation_id", null: false
t.string "f_name"
t.string "m_name"
t.string "l_name"
t.index ["presentation_id"], name: "index_presentation_contributors_on_presentation_id"
end

create_table "presentations", charset: "utf8mb4", force: :cascade do |t|
create_table "presentations", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "faculty_id", null: false
t.string "title"
t.string "dty_date"
Expand All @@ -185,7 +189,7 @@
t.index ["faculty_id"], name: "index_presentations_on_faculty_id"
end

create_table "publication_faculty_links", charset: "utf8mb4", force: :cascade do |t|
create_table "publication_faculty_links", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "faculty_id"
t.bigint "publication_id"
t.string "category"
Expand All @@ -197,14 +201,14 @@
t.index ["publication_id"], name: "fk_rails_7abcf28acb"
end

create_table "publication_listings", charset: "utf8mb4", force: :cascade do |t|
create_table "publication_listings", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "name"
t.string "type"
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
end

create_table "publications", charset: "utf8mb4", force: :cascade do |t|
create_table "publications", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.text "title"
t.integer "volume"
t.integer "dty"
Expand All @@ -231,7 +235,7 @@
t.bigint "rmd_id"
end

create_table "sections", charset: "utf8mb4", force: :cascade do |t|
create_table "sections", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "class_campus_code"
t.string "cross_listed_flag"
t.string "course_number"
Expand All @@ -253,13 +257,13 @@
t.index ["faculty_id", "course_id", "class_campus_code", "subject_code", "course_number", "course_suffix", "class_section_code", "course_component"], name: "pkey", unique: true, length: { class_campus_code: 50, subject_code: 50, course_suffix: 50, class_section_code: 50, course_component: 50 }
end

create_table "sponsors", charset: "utf8mb4", force: :cascade do |t|
create_table "sponsors", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "sponsor_name"
t.string "sponsor_type"
t.index ["sponsor_name"], name: "index_sponsors_on_sponsor_name", unique: true
end

create_table "works", charset: "utf8mb4", force: :cascade do |t|
create_table "works", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "publication_listing_id"
t.text "title"
t.string "journal"
Expand Down Expand Up @@ -290,7 +294,7 @@
t.index ["publication_listing_id"], name: "index_works_on_publication_listing_id"
end

create_table "yearlies", charset: "utf8mb4", force: :cascade do |t|
create_table "yearlies", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "faculty_id"
t.string "academic_year"
t.string "campus"
Expand Down
Loading
Loading