today_ai_weather/db/seeds.rb
songtianlun 517e3038cc chore: rename docker workflows and clean up city seeds
- Rename docker workflow files for clarity: 'docker-dev' and 'docker-main'
- Remove unused city seed files to streamline the database seeding process

These changes improve the organization of the workflow files and reduce clutter in the seed data, making it easier to manage and maintain the project.
2025-02-21 10:02:36 +08:00

203 lines
6.5 KiB
Ruby

# This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Example:
#
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
# MovieGenre.find_or_create_by!(name: genre_name)
# end
# AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development?
AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password')
# 创建区域
regions = Region.create!([
{
name: 'Asia',
code: 'AS'
# },
# {
# name: 'Africa',
# code: 'AF'
# },
# {
# name: 'Europe',
# code: 'EU'
# },
# {
# 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 }
])
# 创建城市
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
},
{
name: 'Beijing',
latitude: 39.9042,
longitude: 116.4074,
country: china,
timezone: 'Asia/Shanghai',
active: true,
priority: 100
},
{
name: 'Shenzhen',
latitude: 22.5431,
longitude: 114.0579,
country: china,
timezone: 'Asia/Shanghai',
active: true,
priority: 100
},
{
name: 'Guangzhou',
latitude: 23.1291,
longitude: 113.2644,
country: china,
timezone: 'Asia/Shanghai',
active: true,
priority: 100
}
])
guangzhou = City.find_by name: 'Guangzhou'
guangzhou_weather_art = WeatherArt.create!(
city: guangzhou,
weather_date: 5.day.ago,
description: 'Sunny with some clouds',
temperature: 28.5,
feeling_temp: 30.2,
humidity: 65,
wind_scale: "3级",
wind_speed: 15,
precipitation: 0,
pressure: 1013,
visibility: 10,
cloud: 30,
prompt: "A sunny day in Guangzhou with modern buildings under blue sky and white clouds, digital art style"
)
guangzhou_weather_art.image.attach(
io: File.open("db/seeds/images/sample-guangzhou-weather-art.png"),
filename: "sample-guangzhou-weather-art.png",
content_type: "image/png"
)
guangzhou_weather_art2 = WeatherArt.create!(
city: guangzhou,
weather_date: 2.day.ago,
description: 'Sunny with some clouds',
temperature: 23.21,
feeling_temp: 22.11,
humidity: 65,
wind_scale: "0.7",
wind_speed: 15,
precipitation: 0,
pressure: 1014,
visibility: 10000,
cloud: 30,
prompt: "A clear day in Guangzhou, China. In the foreground, people are walking near the iconic Canton Tower, surrounded by vibrant greenery and modern buildings. The sky is blue with no clouds, and the sun is shining brightly. It's a perfect day, with a temperature of around 23 degrees Celsius. The scene captures the lively atmosphere of the city, showing locals enjoying their day out."
)
guangzhou_weather_art2.image.attach(
io: File.open("db/seeds/images/sample-guangzhou-weather-art-2.png"),
filename: "sample-guangzhou-weather-art-2.png",
content_type: "image/png"
)
guangzhou_weather_art3 = WeatherArt.create!(
city: guangzhou,
weather_date: 2.day.ago,
description: 'Sunny with some clouds',
temperature: 23.21,
feeling_temp: 22.11,
humidity: 65,
wind_scale: "0.7",
wind_speed: 15,
precipitation: 0,
pressure: 1014,
visibility: 10000,
cloud: 30,
prompt: "A clear day in Guangzhou, China. In the foreground, people are walking near the iconic Canton Tower, surrounded by vibrant greenery and modern buildings. The sky is blue with no clouds, and the sun is shining brightly. It's a perfect day, with a temperature of around 23 degrees Celsius. The scene captures the lively atmosphere of the city, showing locals enjoying their day out."
)
guangzhou_weather_art3.image.attach(
io: File.open("db/seeds/images/sample-guangzhou-weather-art-2.png"),
filename: "sample-guangzhou-weather-art-2.png",
content_type: "image/png"
)