refactor: tidy up code style and remove unused fields
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
Docker / docker (push) Waiting to run

- Added a space in the array passed to `add_index` in the migration
- Removed unused columns `last_weather_fetch` and `last_image_generation` from the `cities` table
- Ensured consistent code style in the `GenerateWeatherArtWorker` and added required newline at the end of files

These changes improve code readability and maintainability while ensuring that
no unnecessary fields exist in the database schema.
This commit is contained in:
songtianlun 2025-01-24 00:25:06 +08:00
parent b4af78aa77
commit 7612dd6bd9
3 changed files with 4 additions and 4 deletions

View File

@ -33,4 +33,4 @@ class BatchGenerateWeatherArtsWorker
.where("latest_arts.last_generation_time IS NULL OR latest_arts.last_generation_time < ?", cutoff_time)
.order(:priority)
end
end
end

View File

@ -50,7 +50,7 @@ class GenerateWeatherArtWorker
weather_art.image.attach(
io: File.open(tempfile.path),
filename: generate_filename,
content_type: 'image/png'
content_type: "image/png"
)
weather_art
@ -65,4 +65,4 @@ class GenerateWeatherArtWorker
def generate_filename
"#{city.country.name}-#{city.name.parameterize}-#{Time.current.strftime('%Y%m%d-%H%M%S')}.png"
end
end
end

View File

@ -3,6 +3,6 @@ class RemoveLastFetchFieldsFromCities < ActiveRecord::Migration[8.0]
remove_column :cities, :last_weather_fetch
remove_column :cities, :last_image_generation
add_index :weather_arts, [:city_id, :weather_date]
add_index :weather_arts, [ :city_id, :weather_date ]
end
end