-
Notifications
You must be signed in to change notification settings - Fork 0
Etda Committee import integration #152
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
Merged
Joao Vitor Barros da Silva (jvitorbarros15)
merged 41 commits into
main
from
etda-post-receiver
Apr 9, 2026
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
c723598
Add basic regex to map roles from ETDA API
jvitorbarros15 9ab610c
Fix committee_role_normalizer to pass Rspec
jvitorbarros15 4d4a22c
Fix Dockerfile with updated image version and rubocop corrections
jvitorbarros15 f2fbf9d
Rubocop
jvitorbarros15 8eb2396
Add edta api importer
jvitorbarros15 9ae71a2
Fix name to etda_committee_memberships_xml_builder.rb
jvitorbarros15 804bc0f
Add rspec tests for the api importer
jvitorbarros15 f887c48
Refactor ETDA committee memberships XML builder to use Nokogiri
jvitorbarros15 e898cc7
Setup skeleton for the api client with initialize
usmannsiddiqui 15f502a
Skeleton initialized, didnt save file initially
usmannsiddiqui f488a2b
Finished setting up the parameters for faculty committee
madhurakhandkar eb0e15c
Created rspec tests for committee records client
madhurakhandkar 21063fa
Add .envrc.example for environment configuration
usmannsiddiqui e8df657
Add environment variables to .envrc.example
usmannsiddiqui 2bbed27
Fix API client to use env variable methods
usmannsiddiqui f76696c
changed explanation in envr.example
usmannsiddiqui a40040c
Complete RSpec tests for CommitteeRecordsClient and fix API key header
usmannsiddiqui 740d5bc
Add Committee.delete_all to ApplicationJob cleanup
usmannsiddiqui 70bff3c
Finished rspec tests for committee_records_client
madhurakhandkar 54279de
WIP: Add EtdaImporter skeleton for pulling committee data from ETDA API
usmannsiddiqui 8b3fd0a
Merge branch 'api-client-etda' into etda-post-receiver
usmannsiddiqui be3fc7a
Wire EtdaImporter into ActivityInsightCommitteeJob and fix importer
usmannsiddiqui 8fe4f47
Modified the etda importer and created rspec tests for the etda importer
madhurakhandkar ebc0229
adding rubocop fixes for now
madhurakhandkar 3a0ef49
Rspec tests passed - Fix integrate method to accept target directly i…
usmannsiddiqui 3011030
Fix etda importer spec to correctly test committee creation and error…
usmannsiddiqui aa0093a
Fix rspec tests for committee records client
usmannsiddiqui a832109
deleted 2 redundant files
usmannsiddiqui 74c5441
fixed up regex in committe normalizer and updated envrc.example
usmannsiddiqui 4c30e5a
Rubocop corrections
jvitorbarros15 d086479
Fix Activity Insight dropdown mappings for committee data
usmannsiddiqui 092e2f4
Fix XML tag COMP -> COMPSTAGE to match Activity Insight schema
usmannsiddiqui 7cfbafb
Remove wihtdrawn from determine_comp method
usmannsiddiqui 1f78a66
Remove degree_type and role_other_explanation from committee data pip…
usmannsiddiqui 1442e91
Add migration to drop degree_type and role_other_explanation from com…
usmannsiddiqui 1691ad8
Address PR feedback: remove type_other_explanation, fix migration, up…
usmannsiddiqui 2e902d9
Filter committee imports to last 6 months, remove .irb_history from t…
usmannsiddiqui 0eb5b3b
Update base Docker image to ruby-3.4.9-node-22
usmannsiddiqui 5366429
Merge remote-tracking branch 'origin/main' into etda-post-receiver
usmannsiddiqui 4dca339
Removed type_other_explantion from schema
usmannsiddiqui 1e7b753
Removed submission status from etda_importer and fixed rails logger e…
usmannsiddiqui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Example environment variables for FAMS Tools | ||
| # Copy this file to .envrc and replace with actual values | ||
|
|
||
| export ETDA_API_URL="http://localhost:3000" | ||
| export ETDA_API_TOKEN="generate_a_token_in_ETDA_console" | ||
| export FAMS_WEBSERVICES_USERNAME | ||
| export FAMS_WEBSERVICES_PASSWORD | ||
| export FAMS_MAIN_USERNAME | ||
| export FAMS_MAIN_PASSWORD | ||
| export FAMS_BACKUPS_SERVICE_USERNAME | ||
| export FAMS_BACKUPS_SERVICE_PASSWORD | ||
| export FAMS_METADATA_DB_KEY | ||
| export FAMS_S3_BUCKET_API_KEY | ||
| export FAMS_LP_SFTP_USERNAME | ||
| export FAMS_LP_SFTP_HOST |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,3 +44,4 @@ spec/examples.txt | |
| .envrc | ||
| .irb_history | ||
| .DS_Store | ||
| CLAUDE.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| require 'etda/committee_records_client' | ||
|
|
||
| module CommitteeData | ||
| class EtdaImporter | ||
| class DegreeTypeError < RuntimeError; end | ||
|
|
||
| def import_all | ||
| Faculty.find_each do |faculty| | ||
| import_for_faculty(faculty) | ||
| rescue Etda::CommitteeRecordsClient::CommitteeRecordsClientError => e | ||
| Rails.logger.error("Failed to import committees for #{faculty.access_id}: #{e.message}") | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def import_for_faculty(faculty) | ||
| result = Etda::CommitteeRecordsClient.new.faculty_committees(faculty.access_id) | ||
| committees_data = result[:data]['committees'] | ||
|
|
||
| committees_data.each do |committee| | ||
| next unless within_last_six_months?(committee['approval_started_at']) | ||
|
|
||
| normalized_role = CommitteeRoleNormalizer.normalize(committee['role']) | ||
|
|
||
| faculty.committees.create!( | ||
| student_fname: committee['student_fname'], | ||
| student_lname: committee['student_lname'], | ||
| role: normalized_role, | ||
| thesis_title: committee['title'], | ||
| type_of_work: map_type_of_work(committee['degree_type']), | ||
| 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']) | ||
| ) | ||
| end | ||
|
|
||
| Rails.logger.info("Imported #{committees_data.length} committees for #{faculty.access_id}") | ||
| end | ||
|
|
||
| def map_type_of_work(degree_type) | ||
| return nil if degree_type.blank? | ||
|
|
||
| case degree_type.strip | ||
| when 'Master Thesis' | ||
| "Master's Committee" | ||
| when 'Dissertation' | ||
| 'Dissertation Committee' | ||
| when 'Thesis' | ||
| 'Undergraduate Honors Thesis' | ||
| when 'Final Paper' | ||
| "Master's Paper Committee" | ||
|
|
||
| else | ||
| raise DegreeTypeError, "Unexpected Degree Type: #{degree_type.strip}" | ||
| end | ||
| end | ||
|
|
||
| def extract_year(date_string) | ||
| return nil if date_string.blank? | ||
|
|
||
| Date.parse(date_string).year | ||
| rescue ArgumentError | ||
| nil | ||
| end | ||
|
|
||
| def within_last_six_months?(date_string) | ||
| return false if date_string.blank? | ||
|
|
||
| Date.parse(date_string) >= 6.months.ago | ||
| end | ||
|
|
||
| def determine_completion_stage(final_submission_approved_at) | ||
| return 'Completed' if final_submission_approved_at.present? | ||
|
|
||
| 'In Process' | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,5 +86,6 @@ def delete_all_data | |
| Yearly.delete_all | ||
| ComEffort.delete_all | ||
| ComQuality.delete_all | ||
| Committee.delete_all | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| class CommitteeRoleNormalizer | ||
| PRIORITY_REGEX = [ | ||
| ['Co-Chairperson', %r{(co[-\s]?chair|co[-\s]?chairperson|committee chair/co-chair)}i], | ||
| ['Chairperson', /(chairperson|chair of committee|committee chair|chair.)/i], | ||
| ['Co-Advisor', /(co[-\s]?dissertation\s*advis(or|er)|co[-\s]?advisor)/i], | ||
| ['Advisor', /(dissertation\s*advis(?:o?r|er)|advis(?:o?r|er))/i], | ||
| ['Supervisor', /supervisor/i], | ||
| ['Mentor', /mentor/i], | ||
| ['Second Reader', /second\s+reader/i], | ||
| ['Reader', /reader/i], | ||
| ['Member', /(member|rep|represent|representative|substitute)/i] | ||
|
|
||
| ].freeze | ||
|
|
||
| def self.normalize(raw_name) | ||
| text = raw_name.to_s.strip | ||
| return 'Other' if text.empty? | ||
|
|
||
| PRIORITY_REGEX.each do |label, regex| | ||
| return label if text.match?(regex) | ||
| end | ||
|
|
||
| 'Other' | ||
| end | ||
| end |
10 changes: 10 additions & 0 deletions
10
db/migrate/20260324000000_add_activity_insight_fields_to_committees.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class AddActivityInsightFieldsToCommittees < ActiveRecord::Migration[7.2] | ||
| def change | ||
| change_table :committees, bulk: true do |t| | ||
| t.string :type_of_work | ||
| t.string :stage_of_completion | ||
| t.integer :start_year | ||
| t.integer :completion_year | ||
| end | ||
| end | ||
| end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20260326000000_remove_degree_type_and_role_other_from_committees.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class RemoveDegreeTypeAndRoleOtherFromCommittees < ActiveRecord::Migration[7.0] | ||
| def change | ||
| remove_column :committees, :degree_type, :string | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| require './lib/etda/committee_records_client' | ||
| require 'httparty' | ||
| module Etda | ||
| class CommitteeRecordsClient | ||
| class CommitteeRecordsClientError < StandardError; end | ||
|
|
||
| def faculty_committees(access_id) | ||
| response = HTTParty.post( | ||
| "#{base_url}/api/v1/committee_records/faculty_committees", | ||
| headers: headers, | ||
| body: body(access_id) | ||
| ) | ||
|
|
||
| handle_response(response) | ||
|
|
||
| # Tells us the error with committe records client with the error itself | ||
| rescue StandardError => e | ||
| raise CommitteeRecordsClientError, e.message | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def base_url | ||
| @base_url ||= ENV.fetch('ETDA_API_URL', 'http://localhost:3000') | ||
| end | ||
|
|
||
| def api_token | ||
| @api_token ||= ENV.fetch('ETDA_API_TOKEN', 'abc123') | ||
| end | ||
|
|
||
| def headers | ||
| { | ||
| 'X-API-KEY' => api_token, | ||
| 'Content-Type' => 'application/json' | ||
| } | ||
| end | ||
|
|
||
| def body(access_id) | ||
| { | ||
| access_id: access_id | ||
| }.to_json | ||
| end | ||
|
|
||
| def handle_response(response) | ||
| raise CommitteeRecordsClientError, response.parsed_response['error'] || 'Unknown error' unless response.success? | ||
|
|
||
| { | ||
| success: true, | ||
| data: response.parsed_response | ||
| } | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This line should be added back, I just wanted you to remove the extra string quotes that were added.
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.
Added back the config/database.yml line
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.
About .irb_history file. Removed it from git tracking with git rm --cached .irb_history