@@ -808,26 +808,23 @@ def upload_to_airtable!
808808 has_override = approved_design_reviews . any? { |r | r . hours_override . present? } ||
809809 approved_build_reviews . any? { |r | r . hours_override . present? }
810810
811+ # Calculate total hours from ALL journal entries (used for self-reported fallback)
812+ total_hours_logged = journal_entries . sum ( :duration_seconds ) / 3600.0
813+
811814 # Check if this is an LED project
812815 if ysws == "led"
813- # if !has_override
814- # hours_for_airtable = 5
815- # else
816- total_effective_hours = 0
817- approved_design_reviews . each { |r | total_effective_hours += r . effective_hours }
818- approved_build_reviews . each { |r | total_effective_hours += r . effective_hours }
819- hours_for_airtable = total_effective_hours
820- # end
816+ total_effective_hours = 0
817+ approved_design_reviews . each { |r | total_effective_hours += r . effective_hours }
818+ approved_build_reviews . each { |r | total_effective_hours += r . effective_hours }
819+ hours_for_airtable = total_effective_hours
820+ self_reported_hours = total_hours_logged
821821 reasoning = "This project followed the 555 LED blinker guide. This was a guide that we have used at workshops before and which took students new to hardware a minimum of 5 hours to complete. This project at least meets the standards of a project submitted at this event. - Clay"
822822 elsif ysws == "hackpad"
823- # if !has_override
824- # hours_for_airtable = 15
825- # else
826- total_effective_hours = 0
827- approved_design_reviews . each { |r | total_effective_hours += r . effective_hours }
828- approved_build_reviews . each { |r | total_effective_hours += r . effective_hours }
829- hours_for_airtable = total_effective_hours
830- # end
823+ total_effective_hours = 0
824+ approved_design_reviews . each { |r | total_effective_hours += r . effective_hours }
825+ approved_build_reviews . each { |r | total_effective_hours += r . effective_hours }
826+ hours_for_airtable = total_effective_hours
827+ self_reported_hours = ( approved_design_reviews . any? && approved_build_reviews . empty? && approx_hour . present? ) ? approx_hour . to_f : total_hours_logged
831828 reasoning = "This is a hackpad submitted for Blueprint initially reviewed by a hack clubber and then given a final pass by either @CAN or @alexren before being submitted to unified.
832829
833830Hours are set to the author's self reported total if it is between 5-20 hours, as the median was 15 based on 400+ individual hackpads that were hand reviewed and verified.
@@ -836,26 +833,21 @@ def upload_to_airtable!
836833
837834Any issues should go to @alexren."
838835 elsif ysws == "squeak"
839- # if !has_override
840- # hours_for_airtable = 5
841- # else
842- total_effective_hours = 0
843- approved_design_reviews . each { |r | total_effective_hours += r . effective_hours }
844- approved_build_reviews . each { |r | total_effective_hours += r . effective_hours }
845- hours_for_airtable = total_effective_hours
846- # end
836+ total_effective_hours = 0
837+ approved_design_reviews . each { |r | total_effective_hours += r . effective_hours }
838+ approved_build_reviews . each { |r | total_effective_hours += r . effective_hours }
839+ hours_for_airtable = total_effective_hours
840+ self_reported_hours = total_hours_logged
847841 reasoning = "This project followed the Squeak guide. This project at least meets the standards of a project submitted at this event."
848842 else
849- # Calculate total hours from ALL journal entries
850- total_hours_logged = journal_entries . sum ( :duration_seconds ) / 3600.0
851-
852843 # Calculate total effective hours from all approved reviews (design + build)
853844 total_effective_hours = 0
854845 approved_design_reviews . each { |r | total_effective_hours += r . effective_hours }
855846 approved_build_reviews . each { |r | total_effective_hours += r . effective_hours }
856847
857848 # Use total effective hours if any reviews exist, otherwise use total logged
858849 hours_for_airtable = ( approved_design_reviews . any? || approved_build_reviews . any? ) ? total_effective_hours : total_hours_logged
850+ self_reported_hours = total_hours_logged
859851
860852 reasoning = "This user logged #{ total_hours_logged . round ( 1 ) } hours across #{ pluralize ( journal_entries . count , 'journal entry' ) } .\n \n \n "
861853
@@ -897,7 +889,7 @@ def upload_to_airtable!
897889 "Project Name" => title ,
898890 "Requested Grant Amount" => grant ? ( grant / 100.0 ) : nil ,
899891 "Grant Tier" => tier ,
900- "Hours Self-Reported" => journal_entries . sum ( :duration_seconds ) / 3600.0 ,
892+ "Hours Self-Reported" => self_reported_hours ,
901893 "Checkout Screens" => ( cart_screenshots . attached? ? cart_screenshots . map { |s |
902894 {
903895 "url" => Rails . application . routes . url_helpers . rails_blob_url ( s , host : ENV . fetch ( "APPLICATION_HOST" ) ) ,
0 commit comments