songtianlun
d728d7f50e
- Created BatchGenerateWeatherArtsJob to process eligible cities and generate weather art. - Introduced GenerateWeatherArtJob for generating weather art and image attachment. - Added AiService for obtaining prompts and generating images with OpenAI API. - Implemented WeatherService to fetch current weather data from the QWeather API. - Updated Gemfile with necessary gems (whenever, ruby-openai, httparty, down, aws-sdk-s3). This commit introduces a system to create and store weather art images for various cities based on current weather conditions, leveraging external APIs for data and image generation.
49 lines
1.0 KiB
Ruby
49 lines
1.0 KiB
Ruby
usa = Country.find_by code: 'US'
|
|
|
|
City.create!([
|
|
{
|
|
name: 'San Francisco',
|
|
latitude: 37.7749,
|
|
longitude: -122.4194,
|
|
country: usa,
|
|
timezone: 'America/Los_Angeles',
|
|
active: false,
|
|
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: false,
|
|
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: false,
|
|
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: false,
|
|
priority: 100,
|
|
last_weather_fetch: 10.hours.ago,
|
|
last_image_generation: 10.hours.ago
|
|
}
|
|
])
|