Skip to content

Commit

Permalink
Add Hackathon#apac? as a temporary solution for #106
Browse files Browse the repository at this point in the history
  • Loading branch information
garyhtou committed Aug 14, 2023
1 parent b3dcc93 commit b5b2dbb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
12 changes: 12 additions & 0 deletions app/models/hackathon/regional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ def country
ISO3166::Country[country_code]&.common_name
end

# TODO: This method and the `apac` column is a temporary solution!
# The column contains the migrated `apac` boolean from Airtable. Newly created
# hackathons (after the migration) will have the `apac` column set to `nil`,
# where it uses on the Country gem to determine if the hackathon is in APAC.
#
# See https://github.com/hackclub/hackathons-backend/issues/106
def apac?
return apac unless apac.nil?

ISO3166::Country[country_code]&.world_region == "APAC"
end

def to_location
Location.new(city, province, country_code)
end
Expand Down
3 changes: 3 additions & 0 deletions app/views/api/hackathons/_hackathon.json.v1.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ shape_for hackathon, json do
json.longitude hackathon.longitude
json.latitude hackathon.latitude
end

# This is temporary! See `Hackathon.apac?` for more info.
json.apac hackathon.apac?
end
5 changes: 5 additions & 0 deletions db/migrate/20230814030407_add_apac_to_hackathon.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddApacToHackathon < ActiveRecord::Migration[7.0]
def change
add_column :hackathons, :apac, :boolean
end
end
5 changes: 3 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5b2dbb

Please sign in to comment.