From 7612dd6bd9300b4cc845899012a18bcd73edb9b9 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Fri, 24 Jan 2025 00:25:06 +0800 Subject: [PATCH] refactor: tidy up code style and remove unused fields - 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. --- app/workers/batch_generate_weather_arts_worker.rb | 2 +- app/workers/generate_weather_art_worker.rb | 4 ++-- .../20250123155234_remove_last_fetch_fields_from_cities.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/workers/batch_generate_weather_arts_worker.rb b/app/workers/batch_generate_weather_arts_worker.rb index 8581d03..85062bf 100644 --- a/app/workers/batch_generate_weather_arts_worker.rb +++ b/app/workers/batch_generate_weather_arts_worker.rb @@ -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 \ No newline at end of file +end diff --git a/app/workers/generate_weather_art_worker.rb b/app/workers/generate_weather_art_worker.rb index 9d4c9d6..0412798 100644 --- a/app/workers/generate_weather_art_worker.rb +++ b/app/workers/generate_weather_art_worker.rb @@ -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 \ No newline at end of file +end diff --git a/db/migrate/20250123155234_remove_last_fetch_fields_from_cities.rb b/db/migrate/20250123155234_remove_last_fetch_fields_from_cities.rb index b06d7e3..74da181 100644 --- a/db/migrate/20250123155234_remove_last_fetch_fields_from_cities.rb +++ b/db/migrate/20250123155234_remove_last_fetch_fields_from_cities.rb @@ -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