From d729e61108edc9d353a52c1f1232b0ca348ff00c Mon Sep 17 00:00:00 2001 From: Polly Sileo Date: Sat, 16 May 2026 18:27:08 -0400 Subject: [PATCH] Gap is GAP not GPS --- db/seeds/partials/stocks.rb | 2 +- script/migrate_returning_students.rb | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/db/seeds/partials/stocks.rb b/db/seeds/partials/stocks.rb index dc5ef389..26b44797 100644 --- a/db/seeds/partials/stocks.rb +++ b/db/seeds/partials/stocks.rb @@ -21,7 +21,7 @@ archived_seed_stocks = [ { ticker: "DIS", company_name: "Disney" }, { ticker: "EA", company_name: "Electronic Arts" }, - { ticker: "GPS", company_name: "Gap" }, + { ticker: "GAP", company_name: "Gap" }, { ticker: "LUV", company_name: "Southwest Airlines" }, { ticker: "META", company_name: "Facebook" }, { ticker: "SIRI", company_name: "SiriusXM" }, diff --git a/script/migrate_returning_students.rb b/script/migrate_returning_students.rb index 97bf5dae..35976f0f 100755 --- a/script/migrate_returning_students.rb +++ b/script/migrate_returning_students.rb @@ -44,7 +44,7 @@ STOCK_COLUMNS = [ { shares_col: COL[:ua_shares], price_col: COL[:ua_price], ticker: "UA" }, { shares_col: COL[:sony_shares], price_col: COL[:sony_price], ticker: "SONY" }, - { shares_col: COL[:gap_shares], price_col: COL[:gap_price], ticker: "GPS" }, + { shares_col: COL[:gap_shares], price_col: COL[:gap_price], ticker: "GAP" }, { shares_col: COL[:ford_shares], price_col: COL[:ford_price], ticker: "F" }, { shares_col: COL[:southwest_shares], price_col: COL[:southwest_price], ticker: "LUV" }, { shares_col: COL[:verizon_shares], price_col: COL[:verizon_price], ticker: "VZ" }, @@ -159,7 +159,12 @@ def quarterly_attendance_days(quarterly_absences) puts "[DRY RUN] Original: #{original_username}#{' (renamed)' if username_changed}" puts "[DRY RUN] Last Year Earnings: $#{earnings}" (1..3).each do |q| - absences = row[ABSENCE_COLS[q]].to_f + raw = row[ABSENCE_COLS[q]] + if raw.blank? + puts "[DRY RUN] Q#{q} Absences: (no record) -> no attendance earnings" + next + end + absences = raw.to_f days = quarterly_attendance_days(absences) earnings_val = format("%.2f", days * 0.20) perfect = absences.zero? ? " (+$1.00 perfect)" : "" @@ -244,9 +249,15 @@ def quarterly_attendance_days(quarterly_absences) next end + raw_absences = row[ABSENCE_COLS[quarter_num]] + if raw_absences.blank? + warnings << "#{username}: Q#{quarter_num} has no attendance record, skipping (no earnings)." + next + end + grade_book = GradeBook.find_or_create_by!(quarter: quarter, classroom: classroom) - quarterly_absences = row[ABSENCE_COLS[quarter_num]].to_f + quarterly_absences = raw_absences.to_f GradeEntry.create!( grade_book: grade_book,