Compare commits
No commits in common. "1ab860c73925b5edd4b77440df0effa3747fd453" and "5fd9573cf22586b7f8ea838bcb83cfd84e48355a" have entirely different histories.
1ab860c739
...
5fd9573cf2
53
.github/workflows/docker.yml
vendored
53
.github/workflows/docker.yml
vendored
@ -1,53 +0,0 @@
|
||||
name: Build and Publish Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
# Use docker.io for Docker Hub if empty
|
||||
REGISTRY: docker.io
|
||||
IMAGE_NAME: ${{ github.event.repository.name }}
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: |
|
||||
GIT_VERSION=$(git describe --dirty --always --long --abbrev=7 --tags)
|
||||
VERSION="v${GIT_VERSION}"
|
||||
IMAGE_PREFIX="${{ env.REGISTRY }}/${{ secrets.DOCKERHUB_USER }}/${{ env.IMAGE_NAME }}"
|
||||
LATEST_TAG="${IMAGE_PREFIX}:latest"
|
||||
VERSION_TAG="${IMAGE_PREFIX}:${VERSION}"
|
||||
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
echo "GIT_VERSION=${GIT_VERSION}" >> $GITHUB_ENV
|
||||
echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_OUTPUT
|
||||
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_OUTPUT
|
||||
-
|
||||
name: Login to ${{ env.REGISTRY }}
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.DOCKERHUB_USER }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ env.LATEST_TAG }},${{ env.VERSION_TAG }}
|
2
Gemfile
2
Gemfile
@ -62,7 +62,7 @@ group :development do
|
||||
end
|
||||
|
||||
group :production do
|
||||
gem "pg", "~> 1.5"
|
||||
gem 'pg', '~> 1.5'
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
@ -10,7 +10,7 @@ ActiveAdmin.register City do
|
||||
#
|
||||
# Uncomment all parameters which should be permitted for assignment
|
||||
#
|
||||
permit_params :name, :country_id, :latitude, :longitude, :active, :priority, :timezone, :last_weather_fetch, :last_image_generation, :slug
|
||||
permit_params :name, :country, :latitude, :longitude, :active, :priority, :timezone, :region, :last_weather_fetch, :last_image_generation, :slug
|
||||
#
|
||||
# or
|
||||
#
|
||||
@ -24,13 +24,11 @@ ActiveAdmin.register City do
|
||||
selectable_column
|
||||
id_column
|
||||
column :name
|
||||
column :country
|
||||
column :region do |city|
|
||||
city.region
|
||||
end
|
||||
column :slug
|
||||
column :latitude
|
||||
column :longitude
|
||||
column :active
|
||||
column :created_at
|
||||
actions
|
||||
end
|
||||
|
||||
@ -41,6 +39,7 @@ 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
|
||||
|
@ -1,36 +0,0 @@
|
||||
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
|
@ -1,29 +0,0 @@
|
||||
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
|
@ -1,11 +1,4 @@
|
||||
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
|
||||
|
@ -1,7 +1,6 @@
|
||||
class City < ApplicationRecord
|
||||
extend FriendlyId
|
||||
friendly_id :name, use: :slugged
|
||||
belongs_to :country
|
||||
|
||||
has_many :weather_arts, dependent: :destroy
|
||||
|
||||
@ -9,20 +8,6 @@ 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
|
||||
|
@ -1,26 +0,0 @@
|
||||
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
|
@ -1,28 +0,0 @@
|
||||
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
|
@ -19,7 +19,7 @@
|
||||
<% end %>
|
||||
|
||||
<div class="card-body relative">
|
||||
<h2 class="card-title font-display text-2xl"><%= city.localized_name %></h2>
|
||||
<h2 class="card-title font-display text-2xl"><%= city.name %></h2>
|
||||
<div class="text-base-content/70">
|
||||
<p>Lat: <%= city.latitude %></p>
|
||||
<p>Long: <%= city.longitude %></p>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
<% end %>
|
||||
<h1 class="text-4xl md:text-5xl font-display font-bold"><%= @city.localized_name %></h1>
|
||||
<h1 class="text-4xl md:text-5xl font-display font-bold"><%= @city.name %></h1>
|
||||
</div>
|
||||
|
||||
<div class="stats bg-base-100/80 backdrop-blur-sm shadow">
|
||||
|
@ -1,118 +0,0 @@
|
||||
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'
|
||||
|
@ -1,118 +0,0 @@
|
||||
|
||||
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: '河内'
|
@ -1,55 +0,0 @@
|
||||
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'
|
@ -1,55 +0,0 @@
|
||||
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: '澳大利亚'
|
@ -1,15 +0,0 @@
|
||||
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'
|
@ -1,15 +0,0 @@
|
||||
zh-CN:
|
||||
regions:
|
||||
AS: '亚洲'
|
||||
SA: '南亚'
|
||||
SEA: '东南亚'
|
||||
EA: '东亚'
|
||||
ME: '中东'
|
||||
AF: '非洲'
|
||||
NA: '北非'
|
||||
SSA: '撒哈拉以南非洲'
|
||||
EU: '欧洲'
|
||||
NAM: '北美洲'
|
||||
SAM: '南美洲'
|
||||
CAM: '中美洲'
|
||||
OC: '大洋洲'
|
@ -1,13 +0,0 @@
|
||||
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
|
@ -1,14 +0,0 @@
|
||||
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
|
@ -1,5 +0,0 @@
|
||||
class AddCountryToCities < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_reference :cities, :country, null: false, foreign_key: true
|
||||
end
|
||||
end
|
@ -1,6 +0,0 @@
|
||||
class RemoveGeographicFieldsFromCities < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
remove_column :cities, :region, :string
|
||||
remove_column :cities, :country, :string
|
||||
end
|
||||
end
|
39
db/schema.rb
generated
39
db/schema.rb
generated
@ -10,17 +10,14 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_01_19_032348) do
|
||||
create_table "active_admin_comments", force: :cascade do |t|
|
||||
t.string "namespace"
|
||||
t.text "body"
|
||||
t.string "resource_type"
|
||||
t.bigint "resource_id"
|
||||
t.integer "resource_id"
|
||||
t.string "author_type"
|
||||
t.bigint "author_id"
|
||||
t.integer "author_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author"
|
||||
@ -70,33 +67,21 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) 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.bigint "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.bigint "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
|
||||
@ -108,18 +93,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) 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.bigint "city_id", null: false
|
||||
t.integer "city_id", null: false
|
||||
t.date "weather_date"
|
||||
t.string "description"
|
||||
t.decimal "temperature"
|
||||
@ -139,7 +114,5 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) 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
|
||||
|
139
db/seeds.rb
139
db/seeds.rb
@ -9,146 +9,15 @@
|
||||
# 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')
|
||||
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: asia },
|
||||
{ name: 'Pakistan', code: 'PK', region: asia },
|
||||
{ name: 'Bangladesh', code: 'BD', region: 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 },
|
||||
|
||||
# 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 },
|
||||
|
||||
# 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 },
|
||||
|
||||
# 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: 'CN')
|
||||
guangzhou = City.create!(
|
||||
name: 'Guangzhou',
|
||||
country: 'China',
|
||||
latitude: 23.1291,
|
||||
longitude: 113.2644,
|
||||
priority: 50,
|
||||
country: china,
|
||||
timezone: 'Asia/Shanghai',
|
||||
active: true,
|
||||
priority: 50,
|
||||
timezone: 'Asia/Shanghai',
|
||||
region: 'Asia',
|
||||
last_weather_fetch: 10.hours.ago,
|
||||
last_image_generation: 10.hours.ago
|
||||
)
|
||||
|
@ -1,26 +0,0 @@
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
brazil = Country.find_by code: 'BR'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,12 +0,0 @@
|
||||
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
|
||||
)
|
@ -1,422 +0,0 @@
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
egypt = Country.find_by code: 'EG'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
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
|
||||
}
|
||||
])
|
@ -1,26 +0,0 @@
|
||||
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
|
||||
}
|
||||
])
|
@ -1,26 +0,0 @@
|
||||
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
|
||||
}
|
||||
])
|
@ -1,26 +0,0 @@
|
||||
japan = Country.find_by code: 'JP'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
mexico = Country.find_by code: 'MX'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
nigeria = Country.find_by code: 'NG'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
pakistan = Country.find_by code: 'PK'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,26 +0,0 @@
|
||||
russia = Country.find_by code: 'RU'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
saudi_arabia = Country.find_by code: 'CA'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
singapore = Country.find_by code: 'SG'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
south_korea = Country.find_by code: 'KR'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
thailand = Country.find_by code: 'TH'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,26 +0,0 @@
|
||||
turkey = Country.find_by code: 'TR'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,15 +0,0 @@
|
||||
uk = Country.find_by code: 'GB'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,48 +0,0 @@
|
||||
usa = Country.find_by code: 'US'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
@ -1,26 +0,0 @@
|
||||
vietnam = Country.find_by code: 'VN'
|
||||
|
||||
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
|
||||
}
|
||||
])
|
2
test/fixtures/cities.yml
vendored
2
test/fixtures/cities.yml
vendored
@ -9,6 +9,7 @@
|
||||
# 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
|
||||
@ -22,6 +23,7 @@
|
||||
# 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
|
||||
|
13
test/fixtures/countries.yml
vendored
13
test/fixtures/countries.yml
vendored
@ -1,13 +0,0 @@
|
||||
# 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
|
11
test/fixtures/regions.yml
vendored
11
test/fixtures/regions.yml
vendored
@ -1,11 +0,0 @@
|
||||
# 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
|
@ -1,7 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class CountryTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class RegionTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue
Block a user