Skip to content

Commit

Permalink
Set year in the base proto record
Browse files Browse the repository at this point in the history
  • Loading branch information
moveson committed Nov 27, 2024
1 parent 8c2ed79 commit 9f61f4f
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def set_base_proto_record(struct)
self.base_proto_record = ProtoRecord.new(**struct.to_h)

base_proto_record.transform_as(:historical_fact, organization: organization)
base_proto_record[:year] = Date.current.year
end

def record_lottery_application(struct)
proto_record = base_proto_record.deep_dup
proto_record[:kind] = :lottery_application
proto_record[:year] = lottery_year
proto_record[:comments] = "Ultrasignup order id: #{struct[:Order_ID]}"

proto_records << proto_record
Expand All @@ -63,7 +63,6 @@ def record_volunteer_reported(struct)
if years_count.present? && years_count.positive?
proto_record = base_proto_record.deep_dup
proto_record[:kind] = :volunteer_multi
proto_record[:year] = Date.current.year
proto_record[:quantity] = years_count
proto_record[:comments] = struct[:Volunteer_description]

Expand All @@ -77,7 +76,6 @@ def record_current_qualifier(struct)
if reported_qualifier.present?
proto_record = base_proto_record.deep_dup
proto_record[:kind] = :qualifier_finish
proto_record[:year] = Date.current.year
proto_record[:comments] = reported_qualifier

proto_records << proto_record
Expand All @@ -91,7 +89,6 @@ def record_emergency_contact(struct)
if emergency_contact.present? || emergency_phone.present?
proto_record = base_proto_record.deep_dup
proto_record[:kind] = :emergency_contact
proto_record[:year] = Date.current.year
proto_record[:comments] = [emergency_contact.presence, emergency_phone.presence].compact.join(", ")

proto_records << proto_record
Expand All @@ -107,7 +104,6 @@ def record_previous_names(struct)

proto_record = base_proto_record.deep_dup
proto_record[:kind] = :previous_name
proto_record[:year] = Date.current.year
proto_record[:comments] = previous_names

proto_records << proto_record
Expand All @@ -121,7 +117,6 @@ def record_ever_finished(struct)
unless reported_ever_finished.blank?
proto_record = base_proto_record.deep_dup
proto_record[:kind] = :ever_finished
proto_record[:year] = Date.current.year
proto_record[:comments] = reported_ever_finished.to_s.downcase

proto_records << proto_record
Expand All @@ -134,15 +129,10 @@ def record_dns_since_finish(struct)
if reported_dns_since_finish.present? && reported_dns_since_finish.to_s.numeric?
proto_record = base_proto_record.deep_dup
proto_record[:kind] = :dns_since_finish
proto_record[:year] = Date.current.year
proto_record[:quantity] = reported_dns_since_finish

proto_records << proto_record
end
end

def lottery_year
@lottery_year ||= Date.current.year + 1
end
end
end

0 comments on commit 9f61f4f

Please sign in to comment.