diff --git a/app/admin/cities.rb b/app/admin/cities.rb index 2cbc254..5698962 100644 --- a/app/admin/cities.rb +++ b/app/admin/cities.rb @@ -10,7 +10,7 @@ ActiveAdmin.register City do # # Uncomment all parameters which should be permitted for assignment # - permit_params :name, :country, :latitude, :longitude, :active, :priority, :timezone, :region, :last_weather_fetch, :last_image_generation, :slug + permit_params :name, :country_id, :latitude, :longitude, :active, :priority, :timezone, :last_weather_fetch, :last_image_generation, :slug # # or # @@ -24,11 +24,13 @@ ActiveAdmin.register City do selectable_column id_column column :name - column :slug + column :country + column :region do |city| + city.region + end column :latitude column :longitude column :active - column :created_at actions end @@ -39,7 +41,6 @@ ActiveAdmin.register City do f.inputs do f.input :active f.input :name - f.input :country, as: :String f.input :latitude f.input :longitude f.input :priority diff --git a/app/admin/countries.rb b/app/admin/countries.rb new file mode 100644 index 0000000..46258ca --- /dev/null +++ b/app/admin/countries.rb @@ -0,0 +1,36 @@ +ActiveAdmin.register Country do + # See permitted parameters documentation: + # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters + # + # Uncomment all parameters which should be permitted for assignment + # + permit_params :name, :code, :region_id + # + # or + # + # permit_params do + # permitted = [:name, :code, :slug, :region_id] + # permitted << :other if params[:action] == 'create' && current_user.admin? + # permitted + # end + index do + selectable_column + id_column + column :name + column :code + column :region + column :cities_count do |country| + country.cities.count + end + actions + end + + form do |f| + f.inputs do + f.input :region + f.input :name + f.input :code + end + f.actions + end +end diff --git a/app/admin/regions.rb b/app/admin/regions.rb new file mode 100644 index 0000000..494ea4c --- /dev/null +++ b/app/admin/regions.rb @@ -0,0 +1,29 @@ +ActiveAdmin.register Region do + # See permitted parameters documentation: + # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters + # + # Uncomment all parameters which should be permitted for assignment + # + permit_params :name, :code + # + # or + # + # permit_params do + # permitted = [:name, :code, :slug] + # permitted << :other if params[:action] == 'create' && current_user.admin? + # permitted + # end + index do + selectable_column + id_column + column :name + column :code + column :countries_count do |region| + region.countries.count + end + column :cities_count do |region| + region.cities.count + end + actions + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0d95db2..1ae736c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,11 @@ class ApplicationController < ActionController::Base # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. allow_browser versions: :modern + before_action :set_locale + + private + + def set_locale + I18n.locale = params[:locale] || I18n.default_locale + end end diff --git a/app/models/city.rb b/app/models/city.rb index cb86220..28b42b9 100644 --- a/app/models/city.rb +++ b/app/models/city.rb @@ -1,6 +1,7 @@ class City < ApplicationRecord extend FriendlyId friendly_id :name, use: :slugged + belongs_to :country has_many :weather_arts, dependent: :destroy @@ -8,6 +9,20 @@ class City < ApplicationRecord validates :latitude, presence: true validates :longitude, presence: true + delegate :region, to: :country + + def to_s + name + end + + def localized_name + I18n.t("cities.#{name.parameterize.underscore}") + end + + def full_name + "#{name}, #{country}" + end + def should_generate_new_friendly_id? name_changed? || super end diff --git a/app/models/country.rb b/app/models/country.rb new file mode 100644 index 0000000..c4a5490 --- /dev/null +++ b/app/models/country.rb @@ -0,0 +1,26 @@ +class Country < ApplicationRecord + extend FriendlyId + friendly_id :name, use: :slugged + + belongs_to :region + has_many :cities, dependent: :restrict_with_error + + validates :name, presence: true + validates :code, presence: true, uniqueness: true + + def to_s + name + end + + def localized_name + I18n.t("countries.#{code}") + end + + def self.ransackable_attributes(auth_object = nil) + [ "code", "created_at", "id", "id_value", "name", "region_id", "slug", "updated_at" ] + end + + def self.ransackable_associations(auth_object = nil) + [ "cities", "region" ] + end +end diff --git a/app/models/region.rb b/app/models/region.rb new file mode 100644 index 0000000..79ce024 --- /dev/null +++ b/app/models/region.rb @@ -0,0 +1,28 @@ +class Region < ApplicationRecord + extend FriendlyId + friendly_id :name, use: :slugged + + has_many :countries, dependent: :restrict_with_error + has_many :cities, through: :countries + + validates :name, presence: true + validates :code, presence: true, uniqueness: true + + def to_s + name + end + + def localized_name + I18n.t("regions.#{code}") + end + + # 模型中允许被搜索的关联 + def self.ransackable_associations(auth_object = nil) + [ "countries", "cities" ] + end + + # 允许被搜索的属性列表 + def self.ransackable_attributes(auth_object = nil) + [ "code", "created_at", "id", "id_value", "name", "slug", "updated_at" ] + end +end diff --git a/config/locales/cities.en.yml b/config/locales/cities.en.yml new file mode 100644 index 0000000..3937a2c --- /dev/null +++ b/config/locales/cities.en.yml @@ -0,0 +1,118 @@ +en: + cities: + # Australia + sydney: 'Sydney' + melbourne: 'Melbourne' + + # Bangladesh + dhaka: 'Dhaka' + + # Brazil + rio_de_janeiro: 'Rio de Janeiro' + + # Canada + toronto: 'Toronto' + + # China + shanghai: 'Shanghai' + beijing: 'Beijing' + shenzhen: 'Shenzhen' + guangzhou: 'Guangzhou' + chengdu: 'Chengdu' + tianjin: 'Tianjin' + wuhan: 'Wuhan' + dongguan: 'Dongguan' + chongqing: 'Chongqing' + xian: "Xi'an" + hangzhou: 'Hangzhou' + foshan: 'Foshan' + nanjing: 'Nanjing' + hong_kong: 'Hong Kong' + shenyang: 'Shenyang' + zhengzhou: 'Zhengzhou' + qingdao: 'Qingdao' + suzhou: 'Suzhou' + changsha: 'Changsha' + jinan: 'Jinan' + kunming: 'Kunming' + harbin: 'Harbin' + shijiazhuang: 'Shijiazhuang' + hefei: 'Hefei' + dalian: 'Dalian' + xiamen: 'Xiamen' + nanning: 'Nanning' + changchun: 'Changchun' + taiyuan: 'Taiyuan' + new_taipei_city: 'New Taipei City' + guiyang: 'Guiyang' + wuxi: 'Wuxi' + shantou: 'Shantou' + urumqi: 'Ürümqi' + zhongshan: 'Zhongshan' + ningbo: 'Ningbo' + fuzhou: 'Fuzhou' + nanchang: 'Nanchang' + + # Democratic Republic of the Congo + kinshasa: 'Kinshasa' + + # Egypt + alexandria: 'Alexandria' + + # France + paris: 'Paris' + + # Germany + frankfurt: 'Frankfurt' + berlin: 'Berlin' + + # India + mumbai: 'Mumbai' + bengaluru: 'Bengaluru' + + # Japan + tokyo: 'Tokyo' + yokohama: 'Yokohama' + + # Mexico + mexico_city: 'Mexico City' + + # Nigeria + lagos: 'Lagos' + + # Pakistan + lahore: 'Lahore' + + # Russia + moscow: 'Moscow' + sankt_petersburg: 'Sankt Petersburg' + + # Saudi Arabia + riyadh: 'Riyadh' + + # Singapore + singapore: 'Singapore' + + # South Korea + seoul: 'Seoul' + + # Thailand + bangkok: 'Bangkok' + + # Turkey + istanbul: 'İstanbul' + ankara: 'Ankara' + + # United Kingdom + london: 'London' + + # United States + san_francisco: 'San Francisco' + chicago: 'Chicago' + new_york_city: 'New York City' + los_angeles: 'Los Angeles' + + # Vietnam + ho_chi_minh_city: 'Ho Chi Minh City' + hanoi: 'Hanoi' + diff --git a/config/locales/cities.zh-CN.yml b/config/locales/cities.zh-CN.yml new file mode 100644 index 0000000..c862887 --- /dev/null +++ b/config/locales/cities.zh-CN.yml @@ -0,0 +1,118 @@ + +zh-CN: + cities: + # Australia + sydney: '悉尼' + melbourne: '墨尔本' + + # Bangladesh + dhaka: '达卡' + + # Brazil + rio_de_janeiro: '里约热内卢' + + # Canada + toronto: '多伦多' + + # China + shanghai: '上海' + beijing: '北京' + shenzhen: '深圳' + guangzhou: '广州' + chengdu: '成都' + tianjin: '天津' + wuhan: '武汉' + dongguan: '东莞' + chongqing: '重庆' + xian: '西安' + hangzhou: '杭州' + foshan: '佛山' + nanjing: '南京' + hong_kong: '香港' + shenyang: '沈阳' + zhengzhou: '郑州' + qingdao: '青岛' + suzhou: '苏州' + changsha: '长沙' + jinan: '济南' + kunming: '昆明' + harbin: '哈尔滨' + shijiazhuang: '石家庄' + hefei: '合肥' + dalian: '大连' + xiamen: '厦门' + nanning: '南宁' + changchun: '长春' + taiyuan: '太原' + new_taipei_city: '新北市' + guiyang: '贵阳' + wuxi: '无锡' + shantou: '汕头' + urumqi: '乌鲁木齐' + zhongshan: '中山' + ningbo: '宁波' + fuzhou: '福州' + nanchang: '南昌' + + # Democratic Republic of the Congo + kinshasa: '金沙萨' + + # Egypt + alexandria: '亚历山大' + + # France + paris: '巴黎' + + # Germany + frankfurt: '法兰克福' + berlin: '柏林' + + # India + mumbai: '孟买' + bengaluru: '班加罗尔' + + # Japan + tokyo: '东京' + yokohama: '横滨' + + # Mexico + mexico_city: '墨西哥城' + + # Nigeria + lagos: '拉各斯' + + # Pakistan + lahore: '拉合尔' + + # Russia + moscow: '莫斯科' + sankt_petersburg: '圣彼得堡' + + # Saudi Arabia + riyadh: '利雅得' + + # Singapore + singapore: '新加坡' + + # South Korea + seoul: '首尔' + + # Thailand + bangkok: '曼谷' + + # Turkey + istanbul: '伊斯坦布尔' + ankara: '安卡拉' + + # United Kingdom + london: '伦敦' + + # United States + san_francisco: '旧金山' + chicago: '芝加哥' + new_york_city: '纽约' + los_angeles: '洛杉矶' + + # Vietnam + ho_chi_minh_city: '胡志明市' + hanoi: '河内' diff --git a/config/locales/countries.en.yml b/config/locales/countries.en.yml new file mode 100644 index 0000000..7c0b858 --- /dev/null +++ b/config/locales/countries.en.yml @@ -0,0 +1,55 @@ +en: + countries: + # East Asia + CN: 'China' + JP: 'Japan' + KR: 'South Korea' + TW: 'Taiwan' + HK: 'Hong Kong' + + # South Asia + IN: 'India' + PK: 'Pakistan' + BD: 'Bangladesh' + + # Southeast Asia + ID: 'Indonesia' + VN: 'Vietnam' + TH: 'Thailand' + MM: 'Myanmar' + SG: 'Singapore' + + # Middle East + TR: 'Turkey' + IR: 'Iran' + SA: 'Saudi Arabia' + IQ: 'Iraq' + + # Africa + NG: 'Nigeria' + EG: 'Egypt' + CD: 'Democratic Republic of the Congo' + TZ: 'Tanzania' + ZA: 'South Africa' + KE: 'Kenya' + AO: 'Angola' + ML: 'Mali' + CI: 'Ivory Coast' + + # Europe + RU: 'Russia' + GB: 'United Kingdom' + DE: 'Germany' + + # North America + US: 'United States' + MX: 'Mexico' + + # South America + BR: 'Brazil' + PE: 'Peru' + CO: 'Colombia' + CL: 'Chile' + + # Oceania + AU: 'Australia' \ No newline at end of file diff --git a/config/locales/countries.zh-CN.yml b/config/locales/countries.zh-CN.yml new file mode 100644 index 0000000..0547529 --- /dev/null +++ b/config/locales/countries.zh-CN.yml @@ -0,0 +1,55 @@ +zh-CN: + countries: + # East Asia + CN: '中国' + JP: '日本' + KR: '韩国' + TW: '台湾' + HK: '香港' + + # South Asia + IN: '印度' + PK: '巴基斯坦' + BD: '孟加拉国' + + # Southeast Asia + ID: '印度尼西亚' + VN: '越南' + TH: '泰国' + MM: '缅甸' + SG: '新加坡' + + # Middle East + TR: '土耳其' + IR: '伊朗' + SA: '沙特阿拉伯' + IQ: '伊拉克' + + # Africa + NG: '尼日利亚' + EG: '埃及' + CD: '刚果民主共和国' + TZ: '坦桑尼亚' + ZA: '南非' + KE: '肯尼亚' + AO: '安哥拉' + ML: '马里' + CI: '科特迪瓦' + + # Europe + RU: '俄罗斯' + GB: '英国' + DE: '德国' + + # North America + US: '美国' + MX: '墨西哥' + + # South America + BR: '巴西' + PE: '秘鲁' + CO: '哥伦比亚' + CL: '智利' + + # Oceania + AU: '澳大利亚' \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 6c349ae..4e65d5c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -28,4 +28,4 @@ # enabled: "ON" en: - hello: "Hello world" + hello: "Hello world" \ No newline at end of file diff --git a/config/locales/regions.en.yml b/config/locales/regions.en.yml new file mode 100644 index 0000000..8558328 --- /dev/null +++ b/config/locales/regions.en.yml @@ -0,0 +1,15 @@ +en: + regions: + AS: 'Asia' + SA: 'South Asia' + SEA: 'Southeast Asia' + EA: 'East Asia' + ME: 'Middle East' + AF: 'Africa' + NA: 'North Africa' + SSA: 'Sub-Saharan Africa' + EU: 'Europe' + NAM: 'North America' + SAM: 'South America' + CAM: 'Central America' + OC: 'Oceania' \ No newline at end of file diff --git a/config/locales/regions.zh-CN.yml b/config/locales/regions.zh-CN.yml new file mode 100644 index 0000000..14f19f9 --- /dev/null +++ b/config/locales/regions.zh-CN.yml @@ -0,0 +1,15 @@ +zh-CN: + regions: + AS: '亚洲' + SA: '南亚' + SEA: '东南亚' + EA: '东亚' + ME: '中东' + AF: '非洲' + NA: '北非' + SSA: '撒哈拉以南非洲' + EU: '欧洲' + NAM: '北美洲' + SAM: '南美洲' + CAM: '中美洲' + OC: '大洋洲' \ No newline at end of file diff --git a/db/migrate/20250121015832_create_regions.rb b/db/migrate/20250121015832_create_regions.rb new file mode 100644 index 0000000..6e374d8 --- /dev/null +++ b/db/migrate/20250121015832_create_regions.rb @@ -0,0 +1,13 @@ +class CreateRegions < ActiveRecord::Migration[8.0] + def change + create_table :regions do |t| + t.string :name + t.string :code + t.string :slug + + t.timestamps + end + add_index :regions, :code, unique: true + add_index :regions, :slug, unique: true + end +end diff --git a/db/migrate/20250121015841_create_countries.rb b/db/migrate/20250121015841_create_countries.rb new file mode 100644 index 0000000..c6f5836 --- /dev/null +++ b/db/migrate/20250121015841_create_countries.rb @@ -0,0 +1,14 @@ +class CreateCountries < ActiveRecord::Migration[8.0] + def change + create_table :countries do |t| + t.string :name + t.string :code + t.string :slug + t.references :region, null: false, foreign_key: true + + t.timestamps + end + add_index :countries, :code, unique: true + add_index :countries, :slug, unique: true + end +end diff --git a/db/migrate/20250121015849_add_country_to_cities.rb b/db/migrate/20250121015849_add_country_to_cities.rb new file mode 100644 index 0000000..cff302a --- /dev/null +++ b/db/migrate/20250121015849_add_country_to_cities.rb @@ -0,0 +1,5 @@ +class AddCountryToCities < ActiveRecord::Migration[8.0] + def change + add_reference :cities, :country, null: false, foreign_key: true + end +end diff --git a/db/migrate/20250121020653_remove_geographic_fields_from_cities.rb b/db/migrate/20250121020653_remove_geographic_fields_from_cities.rb new file mode 100644 index 0000000..2092bbf --- /dev/null +++ b/db/migrate/20250121020653_remove_geographic_fields_from_cities.rb @@ -0,0 +1,6 @@ +class RemoveGeographicFieldsFromCities < ActiveRecord::Migration[8.0] + def change + remove_column :cities, :region, :string + remove_column :cities, :country, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index de46ad8..2a28d50 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_01_19_032348) do +ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) do create_table "active_admin_comments", force: :cascade do |t| t.string "namespace" t.text "body" @@ -67,21 +67,33 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_19_032348) do create_table "cities", force: :cascade do |t| t.string "name" - t.string "country" t.float "latitude" t.float "longitude" t.boolean "active" t.integer "priority" t.string "timezone" - t.string "region" t.datetime "last_weather_fetch" t.datetime "last_image_generation" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "slug" + t.integer "country_id", null: false + t.index ["country_id"], name: "index_cities_on_country_id" t.index ["slug"], name: "index_cities_on_slug", unique: true end + create_table "countries", force: :cascade do |t| + t.string "name" + t.string "code" + t.string "slug" + t.integer "region_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["code"], name: "index_countries_on_code", unique: true + t.index ["region_id"], name: "index_countries_on_region_id" + t.index ["slug"], name: "index_countries_on_slug", unique: true + end + create_table "friendly_id_slugs", force: :cascade do |t| t.string "slug", null: false t.integer "sluggable_id", null: false @@ -93,6 +105,16 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_19_032348) do t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id" end + create_table "regions", force: :cascade do |t| + t.string "name" + t.string "code" + t.string "slug" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["code"], name: "index_regions_on_code", unique: true + t.index ["slug"], name: "index_regions_on_slug", unique: true + end + create_table "weather_arts", force: :cascade do |t| t.integer "city_id", null: false t.date "weather_date" @@ -114,5 +136,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_19_032348) do add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" + add_foreign_key "cities", "countries" + add_foreign_key "countries", "regions" add_foreign_key "weather_arts", "cities" end diff --git a/db/seeds.rb b/db/seeds.rb index 591fca6..e4dfc6d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,15 +9,150 @@ # end AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development? +WeatherArt.delete_all +City.delete_all +Country.delete_all +Region.delete_all + +# 创建区域 +regions = Region.create!([ + { + name: 'Asia', + code: 'AS' + }, + { + name: 'South Asia', + code: 'SA' + }, + { + name: 'Southeast Asia', + code: 'SEA' + }, + { + name: 'East Asia', + code: 'EA' + }, + { + name: 'Middle East', + code: 'ME' + }, + { + name: 'Africa', + code: 'AF' + }, + { + name: 'North Africa', + code: 'NA' + }, + { + name: 'Sub-Saharan Africa', + code: 'SSA' + }, + { + name: 'Europe', + code: 'EU' + }, + { + name: 'North America', + code: 'NAM' + }, + { + name: 'South America', + code: 'SAM' + }, + { + name: 'Central America', + code: 'CAM' + }, + { + name: 'Oceania', + code: 'OC' + } +]) +asia = Region.find_by(code: 'AS') +south_asia = Region.find_by(code: 'SA') +africa = Region.find_by(code: 'AF') +europe = Region.find_by(code: 'EU') +north_america = Region.find_by(code: 'NAM') +south_america = Region.find_by(code: 'SAM') +oceania = Region.find_by(code: 'OC') + +# 创建所有国家 +Country.create!([ + # East Asia + { name: 'China', code: 'CN', region: asia }, + { name: 'Japan', code: 'JP', region: asia }, + { name: 'South Korea', code: 'KR', region: asia }, + { name: 'Taiwan', code: 'TW', region: asia }, + { name: 'Hong Kong', code: 'HK', region: asia }, + + # South Asia + { name: 'India', code: 'IN', region: south_asia }, + { name: 'Pakistan', code: 'PK', region: south_asia }, + { name: 'Bangladesh', code: 'BD', region: south_asia }, + + # Southeast Asia + { name: 'Indonesia', code: 'ID', region: asia }, + { name: 'Vietnam', code: 'VN', region: asia }, + { name: 'Thailand', code: 'TH', region: asia }, + { name: 'Myanmar', code: 'MM', region: asia }, + { name: 'Singapore', code: 'SG', region: asia }, + { name: 'Bangladesh', code: 'BD', region: asia }, + + # Middle East + { name: 'Turkey', code: 'TR', region: asia }, + { name: 'Iran', code: 'IR', region: asia }, + { name: 'Saudi Arabia', code: 'SA', region: asia }, + { name: 'Iraq', code: 'IQ', region: asia }, + + # Africa + { name: 'Nigeria', code: 'NG', region: africa }, + { name: 'Egypt', code: 'EG', region: africa }, + { name: 'Democratic Republic of the Congo', code: 'CD', region: africa }, + { name: 'Tanzania', code: 'TZ', region: africa }, + { name: 'South Africa', code: 'ZA', region: africa }, + { name: 'Kenya', code: 'KE', region: africa }, + { name: 'Angola', code: 'AO', region: africa }, + { name: 'Mali', code: 'ML', region: africa }, + { name: 'Ivory Coast', code: 'CI', region: africa }, + { name: 'Egypt', code: 'EGY', region: africa }, + + # Europe + { name: 'Russia', code: 'RU', region: europe }, + { name: 'United Kingdom', code: 'GB', region: europe }, + { name: 'Germany', code: 'DE', region: europe }, + { name: 'France', code: 'FRA', region: europe}, + + # North America + { name: 'United States', code: 'US', region: north_america }, + { name: 'Mexico', code: 'MX', region: north_america }, + { name: 'Canada', code: 'CA', region: north_america }, + + # South America + { name: 'Brazil', code: 'BR', region: south_america }, + { name: 'Peru', code: 'PE', region: south_america }, + { name: 'Colombia', code: 'CO', region: south_america }, + { name: 'Chile', code: 'CL', region: south_america }, + { name: 'Brazil', code: 'BZ', region: south_america }, + + # Oceania + { name: 'Australia', code: 'AU', region: oceania } +]) + +# 创建城市 +Dir[Rails.root.join('db/seeds/cities/*.rb')].sort.each do |file| + require file +end + +china = Country.find_by(code: 'CHN') guangzhou = City.create!( name: 'Guangzhou', - country: 'China', latitude: 23.1291, longitude: 113.2644, - active: true, priority: 50, + country: china, timezone: 'Asia/Shanghai', - region: 'Asia', + active: true, last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago ) diff --git a/db/seeds/cities/australia.rb b/db/seeds/cities/australia.rb new file mode 100644 index 0000000..839fdf7 --- /dev/null +++ b/db/seeds/cities/australia.rb @@ -0,0 +1,26 @@ +australia = Country.find_by code: 'AU' + +City.create!([ + { + name: 'Sydney', + latitude: -33.8688, + longitude: 151.2093, + country: australia, + timezone: 'Australia/Sydney', + active: true, + priority: 80, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Melbourne', + latitude: -37.8136, + longitude: 144.9631, + country: australia, + timezone: 'Australia/Melbourne', + active: true, + priority: 75, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/bangladesh.rb b/db/seeds/cities/bangladesh.rb new file mode 100644 index 0000000..de70562 --- /dev/null +++ b/db/seeds/cities/bangladesh.rb @@ -0,0 +1,15 @@ +bangladesh = Country.find_by code: 'BD' + +City.create!([ + { + name: 'Dhaka', + latitude: 23.8103, + longitude: 90.4125, + country: bangladesh, + timezone: 'Asia/Dhaka', + active: true, + priority: 85, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/brazil.rb b/db/seeds/cities/brazil.rb new file mode 100644 index 0000000..d76851c --- /dev/null +++ b/db/seeds/cities/brazil.rb @@ -0,0 +1,15 @@ +brazil = Country.find_by code: 'BZ' + +City.create!([ + { + name: 'Rio de Janeiro', + latitude: -22.9068, + longitude: -43.1729, + country: brazil, + timezone: 'America/Sao_Paulo', + active: true, + priority: 80, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/canada.rb b/db/seeds/cities/canada.rb new file mode 100644 index 0000000..8a64e1e --- /dev/null +++ b/db/seeds/cities/canada.rb @@ -0,0 +1,12 @@ +canada = Country.find_by code: 'CA' +City.create!( + name: 'Toronto', + latitude: 43.6532, + longitude: -79.3832, + priority: 50, + country: canada, + timezone: 'America/Toronto', + active: true, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago +) \ No newline at end of file diff --git a/db/seeds/cities/china.rb b/db/seeds/cities/china.rb new file mode 100644 index 0000000..e630d78 --- /dev/null +++ b/db/seeds/cities/china.rb @@ -0,0 +1,422 @@ +china = Country.find_by code: 'CN' + +City.create!([ + { + name: 'Shanghai', + latitude: 31.2304, + longitude: 121.4737, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Beijing', + latitude: 39.9042, + longitude: 116.4074, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Shenzhen', + latitude: 22.5431, + longitude: 114.0579, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Guangzhou', + latitude: 23.1291, + longitude: 113.2644, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Chengdu', + latitude: 30.5728, + longitude: 104.0668, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Tianjin', + latitude: 39.3434, + longitude: 117.3616, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Wuhan', + latitude: 30.5928, + longitude: 114.3055, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Dongguan', + latitude: 23.0208, + longitude: 113.7518, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Chongqing', + latitude: 29.4316, + longitude: 106.9123, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: "Xi'an", + latitude: 34.3416, + longitude: 108.9398, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Hangzhou', + latitude: 30.2741, + longitude: 120.1551, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Foshan', + latitude: 23.0219, + longitude: 113.1216, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Nanjing', + latitude: 32.0603, + longitude: 118.7969, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Hong Kong', + latitude: 22.3193, + longitude: 114.1694, + country: china, + timezone: 'Asia/Hong_Kong', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Shenyang', + latitude: 41.8057, + longitude: 123.4315, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Zhengzhou', + latitude: 34.7472, + longitude: 113.6249, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Qingdao', + latitude: 36.0671, + longitude: 120.3826, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Suzhou', + latitude: 31.2990, + longitude: 120.5853, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Changsha', + latitude: 28.2282, + longitude: 112.9388, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Jinan', + latitude: 36.6512, + longitude: 117.1201, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Kunming', + latitude: 25.0389, + longitude: 102.7183, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Harbin', + latitude: 45.8038, + longitude: 126.5340, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Shijiazhuang', + latitude: 38.0428, + longitude: 114.5149, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Hefei', + latitude: 31.8206, + longitude: 117.2272, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Dalian', + latitude: 38.9140, + longitude: 121.6147, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Xiamen', + latitude: 24.4798, + longitude: 118.0819, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Nanning', + latitude: 22.8170, + longitude: 108.3665, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Changchun', + latitude: 43.8171, + longitude: 125.3235, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Taiyuan', + latitude: 37.8706, + longitude: 112.5489, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'New Taipei City', + latitude: 25.0120, + longitude: 121.4657, + country: china, + timezone: 'Asia/Taipei', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Guiyang', + latitude: 26.6470, + longitude: 106.6302, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Wuxi', + latitude: 31.4914, + longitude: 120.3119, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Shantou', + latitude: 23.3535, + longitude: 116.6822, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Ürümqi', + latitude: 43.8256, + longitude: 87.6168, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Zhongshan', + latitude: 22.5415, + longitude: 113.3926, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Ningbo', + latitude: 29.8683, + longitude: 121.5440, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Fuzhou', + latitude: 26.0745, + longitude: 119.2965, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Nanchang', + latitude: 28.6820, + longitude: 115.8579, + country: china, + timezone: 'Asia/Shanghai', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/egypt.rb b/db/seeds/cities/egypt.rb new file mode 100644 index 0000000..1535830 --- /dev/null +++ b/db/seeds/cities/egypt.rb @@ -0,0 +1,15 @@ +egypt = Country.find_by code: 'EGY' + +City.create!([ + { + name: 'Alexandria', + latitude: 31.2001, + longitude: 29.9187, + country: egypt, + timezone: 'Africa/Cairo', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/france.rb b/db/seeds/cities/france.rb new file mode 100644 index 0000000..296778e --- /dev/null +++ b/db/seeds/cities/france.rb @@ -0,0 +1,15 @@ +france = Country.find_by code: 'FRA' + +City.create!([ + { + name: 'Paris', + latitude: 48.8566, + longitude: 2.3522, + country: france, + timezone: 'Europe/Paris', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/germany.rb b/db/seeds/cities/germany.rb new file mode 100644 index 0000000..16433bf --- /dev/null +++ b/db/seeds/cities/germany.rb @@ -0,0 +1,26 @@ +germany = Country.find_by code: 'DE' + +City.create!([ + { + name: 'Frankfurt', + latitude: 50.1109, + longitude: 8.6821, + country: germany, + timezone: 'Europe/Berlin', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Berlin', + latitude: 52.5200, + longitude: 13.4050, + country: germany, + timezone: 'Europe/Berlin', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/india.rb b/db/seeds/cities/india.rb new file mode 100644 index 0000000..17fd3ab --- /dev/null +++ b/db/seeds/cities/india.rb @@ -0,0 +1,26 @@ +india = Country.find_by code: 'IN' + +City.create!([ + { + name: 'Mumbai', + latitude: 19.0760, + longitude: 72.8777, + country: india, + timezone: 'Asia/Kolkata', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Bengaluru', + latitude: 12.9716, + longitude: 77.5946, + country: india, + timezone: 'Asia/Kolkata', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/japan.rb b/db/seeds/cities/japan.rb new file mode 100644 index 0000000..6abce7e --- /dev/null +++ b/db/seeds/cities/japan.rb @@ -0,0 +1,26 @@ +japan = Country.find_by 1 + +City.create!([ + { + name: 'Tokyo', + latitude: 35.6762, + longitude: 139.6503, + country: japan, + timezone: 'Asia/Tokyo', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Yokohama', + latitude: 35.4437, + longitude: 139.6380, + country: japan, + timezone: 'Asia/Tokyo', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/mexico.rb b/db/seeds/cities/mexico.rb new file mode 100644 index 0000000..46cfade --- /dev/null +++ b/db/seeds/cities/mexico.rb @@ -0,0 +1,15 @@ +mexico = Country.find_by 1 + +City.create!([ + { + name: 'Mexico City', + latitude: 19.4326, + longitude: -99.1332, + country: mexico, + timezone: 'America/Mexico_City', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/nigeria.rb b/db/seeds/cities/nigeria.rb new file mode 100644 index 0000000..2ddcd5d --- /dev/null +++ b/db/seeds/cities/nigeria.rb @@ -0,0 +1,15 @@ +nigeria = Country.find_by 1 + +City.create!([ + { + name: 'Lagos', + latitude: 6.5244, + longitude: 3.3792, + country: nigeria, + timezone: 'Africa/Lagos', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/pakistan.rb b/db/seeds/cities/pakistan.rb new file mode 100644 index 0000000..dd2b87d --- /dev/null +++ b/db/seeds/cities/pakistan.rb @@ -0,0 +1,15 @@ +pakistan = Country.find_by 1 + +City.create!([ + { + name: 'Lahore', + latitude: 31.5204, + longitude: 74.3587, + country: pakistan, + timezone: 'Asia/Karachi', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/russia.rb b/db/seeds/cities/russia.rb new file mode 100644 index 0000000..71ee201 --- /dev/null +++ b/db/seeds/cities/russia.rb @@ -0,0 +1,26 @@ +russia = Country.find_by 1 + +City.create!([ + { + name: 'Moscow', + latitude: 55.7558, + longitude: 37.6173, + country: russia, + timezone: 'Europe/Moscow', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Sankt Petersburg', + latitude: 59.9311, + longitude: 30.3609, + country: russia, + timezone: 'Europe/Moscow', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/saudi_arabia.rb b/db/seeds/cities/saudi_arabia.rb new file mode 100644 index 0000000..08bcf9f --- /dev/null +++ b/db/seeds/cities/saudi_arabia.rb @@ -0,0 +1,15 @@ +saudi_arabia = Country.find_by 1 + +City.create!([ + { + name: 'Riyadh', + latitude: 24.7136, + longitude: 46.6753, + country: saudi_arabia, + timezone: 'Asia/Riyadh', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/singapore.rb b/db/seeds/cities/singapore.rb new file mode 100644 index 0000000..384645d --- /dev/null +++ b/db/seeds/cities/singapore.rb @@ -0,0 +1,15 @@ +singapore = Country.find_by 1 + +City.create!([ + { + name: 'Singapore', + latitude: 1.3521, + longitude: 103.8198, + country: singapore, + timezone: 'Asia/Singapore', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/south_korea.rb b/db/seeds/cities/south_korea.rb new file mode 100644 index 0000000..2ecdd17 --- /dev/null +++ b/db/seeds/cities/south_korea.rb @@ -0,0 +1,15 @@ +south_korea = Country.find_by 1 + +City.create!([ + { + name: 'Seoul', + latitude: 37.5665, + longitude: 126.9780, + country: south_korea, + timezone: 'Asia/Seoul', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/thailand.rb b/db/seeds/cities/thailand.rb new file mode 100644 index 0000000..8914fe9 --- /dev/null +++ b/db/seeds/cities/thailand.rb @@ -0,0 +1,15 @@ +thailand = Country.find_by 1 + +City.create!([ + { + name: 'Bangkok', + latitude: 13.7563, + longitude: 100.5018, + country: thailand, + timezone: 'Asia/Bangkok', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/turkey.rb b/db/seeds/cities/turkey.rb new file mode 100644 index 0000000..1a47f69 --- /dev/null +++ b/db/seeds/cities/turkey.rb @@ -0,0 +1,26 @@ +turkey = Country.find_by 1 + +City.create!([ + { + name: 'İstanbul', + latitude: 41.0082, + longitude: 28.9784, + country: turkey, + timezone: 'Europe/Istanbul', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Ankara', + latitude: 39.9334, + longitude: 32.8597, + country: turkey, + timezone: 'Europe/Istanbul', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/uk.rb b/db/seeds/cities/uk.rb new file mode 100644 index 0000000..2692782 --- /dev/null +++ b/db/seeds/cities/uk.rb @@ -0,0 +1,15 @@ +uk = Country.find_by 1 + +City.create!([ + { + name: 'London', + latitude: 51.5074, + longitude: -0.1278, + country: uk, + timezone: 'Europe/London', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/usa.rb b/db/seeds/cities/usa.rb new file mode 100644 index 0000000..91f9eb3 --- /dev/null +++ b/db/seeds/cities/usa.rb @@ -0,0 +1,48 @@ +usa = Country.find_by 1 + +City.create!([ + { + name: 'San Francisco', + latitude: 37.7749, + longitude: -122.4194, + country: usa, + timezone: 'America/Los_Angeles', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Chicago', + latitude: 41.8781, + longitude: -87.6298, + country: usa, + timezone: 'America/Chicago', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'New York City', + latitude: 40.7128, + longitude: -74.0060, + country: usa, + timezone: 'America/New_York', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Los Angeles', + latitude: 34.0522, + longitude: -118.2437, + country: usa, + timezone: 'America/Los_Angeles', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) \ No newline at end of file diff --git a/db/seeds/cities/vietnam.rb b/db/seeds/cities/vietnam.rb new file mode 100644 index 0000000..43cfd86 --- /dev/null +++ b/db/seeds/cities/vietnam.rb @@ -0,0 +1,26 @@ +vietnam = Country.find_by 1 + +City.create!([ + { + name: 'Ho Chi Minh City', + latitude: 10.8231, + longitude: 106.6297, + country: vietnam, + timezone: 'Asia/Ho_Chi_Minh', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + }, + { + name: 'Hanoi', + latitude: 21.0285, + longitude: 105.8542, + country: vietnam, + timezone: 'Asia/Ho_Chi_Minh', + active: true, + priority: 100, + last_weather_fetch: 10.hours.ago, + last_image_generation: 10.hours.ago + } +]) diff --git a/test/fixtures/cities.yml b/test/fixtures/cities.yml index b1abf5f..2780538 100644 --- a/test/fixtures/cities.yml +++ b/test/fixtures/cities.yml @@ -9,7 +9,6 @@ # active: false # priority: 1 # timezone: MyString -# population: 1 # region: MyString # last_weather_fetch: 2025-01-19 10:28:26 # last_image_generation: 2025-01-19 10:28:26 @@ -23,7 +22,6 @@ # active: false # priority: 1 # timezone: MyString -# population: 1 # region: MyString # last_weather_fetch: 2025-01-19 10:28:26 # last_image_generation: 2025-01-19 10:28:26 diff --git a/test/fixtures/countries.yml b/test/fixtures/countries.yml new file mode 100644 index 0000000..e65f3f6 --- /dev/null +++ b/test/fixtures/countries.yml @@ -0,0 +1,13 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +#one: +# name: MyString +# code: MyString +# slug: MyString +# region: one +# +#two: +# name: MyString +# code: MyString +# slug: MyString +# region: two diff --git a/test/fixtures/regions.yml b/test/fixtures/regions.yml new file mode 100644 index 0000000..44929e0 --- /dev/null +++ b/test/fixtures/regions.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +#one: +# name: MyString +# code: MyString +# slug: MyString +# +#two: +# name: MyString +# code: MyString +# slug: MyString diff --git a/test/models/country_test.rb b/test/models/country_test.rb new file mode 100644 index 0000000..5cecb96 --- /dev/null +++ b/test/models/country_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class CountryTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/region_test.rb b/test/models/region_test.rb new file mode 100644 index 0000000..1aa672c --- /dev/null +++ b/test/models/region_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class RegionTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end