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
2 changes: 1 addition & 1 deletion db/seeds/partials/stocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
22 changes: 19 additions & 3 deletions script/migrate_returning_students.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down Expand Up @@ -182,7 +182,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)" : ""
Expand Down Expand Up @@ -262,9 +267,20 @@ def quarterly_attendance_days(quarterly_absences)

GRADE_COLUMNS.each do |quarter_num, cols|
quarter = Quarter.find_by(school_year: school_year, number: quarter_num)
unless quarter
warnings << "#{username}: Quarter #{quarter_num} not found for school year, skipping grade entry."
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,
Expand Down