Commit Graph

87 Commits

Author SHA1 Message Date
9dd7044a77 style: update title in application layout
- Change title from 'AI Weather Art' to 'Today AI Weather Art'

This change enhances the clarity of the application by specifying that the art relates to today's weather. It does not affect any functionality but improves the user interface.
2025-01-24 09:15:51 +08:00
fedb954d34 chore: add Google AdSense script to layout
- Include async script for Google AdSense in the application layout
- Ensure script loads with crossorigin attribute

This change will allow the application to serve ads from Google, potentially generating revenue. The implementation is non-intrusive and maintains existing functionality.
2025-01-24 09:04:41 +08:00
7612dd6bd9 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.
2025-01-24 00:25:06 +08:00
b4af78aa77 feat: add logging and refactor image attachment
- Add logging to track the generation of weather art for each city.
- Refactor image attachment process to streamline the code by removing the
  separate method for attaching images.
- Ensure proper handling of the temporary file used for image processing.

These changes improve observability during the weather art generation
process and encapsulate the image attachment logic within the primary
method, reducing the overhead of a method call. The adjustments also
ensure that temporary files are managed correctly to prevent resource
leaks.
2025-01-24 00:23:09 +08:00
b05cf10017 refactor: simplify city weather generation logic
- Introduced constants for configuration settings such as generation interval, maximum duration, and sleep duration.
- Updated the `perform` method to utilize these constants for better readability and maintainability.
- Refactored the `perform` method in `GenerateWeatherArtWorker` to improve flow and error handling by creating separate methods for fetching weather data, generating prompts, images, and handling database transactions.
- Cleaned up city seeding data by removing unnecessary fields while maintaining required functionality.

These changes improve the overall readability of the code and make it easier to adjust the behavior of the workers in the future without digging through the logic.
2025-01-24 00:14:29 +08:00
06a861c639 refactor: clean up city model and adjust worker timing
- Implement caching methods for last weather fetch and image generation
- Adjust sleep duration in BatchGenerateWeatherArtsWorker from 10 seconds to 3 seconds
- Remove unused fields `last_weather_fetch` and `last_image_generation` from the cities table
- Add index on the weather_arts table for optimized querying

This refactor improves data retrieval performance for weather data
associated with cities. Caching reduces database load while the
worker modification allows for faster iterations in generating
weather arts without significantly impacting performance.
2025-01-23 23:59:48 +08:00
80a75d3fbb feat: add Google Analytics tracking code
- Include gtag.js for Google Analytics
- Setup dataLayer for tracking events
- Configure Google Analytics with unique ID

This commit integrates Google Analytics into the web
application to enable tracking of user interactions and
site usage. It sets up the necessary scripts and initializes
the tracking code with the provided unique ID, improving
analytics capabilities.
2025-01-23 19:49:59 +08:00
f477f205ab fix: update default host in sitemap generator and refresh sitemap on worker
- update default host in sitemap generator
- refresh sitemap on worker with new host

These changes allow the sitemap to be correctly generated for different environments and to handle the new host correctly, which was the motivation behind this update. No other side effects are expected.
2025-01-23 19:40:08 +08:00
1f47ba59c9 style: format code for consistency
- Ensure consistent use of double quotes for strings in the
  Gemfile and sitemap configuration files.
- Add spaces for better readability in array declarations
  within the RefreshSitemapWorker.

These changes improve the readability of the code without
changing any functionality. Adhering to a consistent coding
style helps maintainability and team collaboration.
2025-01-23 19:03:14 +08:00
a0516f731c feat: add SEO meta tags and sitemap generation
- Introduced `SeoConcern` module to handle SEO meta tags
- Integrated `meta-tags` gem for customizable meta tags
- Created `RefreshSitemapWorker` to automate sitemap updates
- Added relevant meta tags in controllers for weather art and cities
- Configured sitemap generation settings

These changes improve the SEO of the application by ensuring that
pages have appropriate meta tags. Additionally, a sitemap is now
generated and refreshed daily, enhancing site visibility to search
engines.
2025-01-23 19:02:52 +08:00
18f751938f feat: update application layout
- Add language attribute to HTML tag
- Update meta viewport attribute for accessibility
- Include Plausible JavaScript tracking script for analytics

This change improves application accessibility by setting the language attribute for the HTML tag, and it enhances data collection capabilities by integrating Plausible analytics tracking.
2025-01-23 17:46:37 +08:00
bafb90f5fb style: format code style in Gemfile and controllers
- Adjust spacing around the quotes in the Gemfile
- Standardize spacing in the arts_controller for improved readability
- Modify routes file for consistent array formatting

These changes enhance the consistency of code style across the project without altering any functionality or behavior.
2025-01-23 17:33:01 +08:00
f33fb4d2ba feat: add pagination to cities and arts index
- Implement pagination for the cities index view.
- Add shared pagination partial to reduce code duplication.
- Modify arts index view to utilize the new pagination.
- Update cities controller to include pagination logic.

These updates improve usability by allowing better navigation through larger datasets, ensuring users can easily access and view items across multiple pages.
2025-01-23 17:30:05 +08:00
a4de04874d feat: implement filtering and pagination for weather arts
- Add region selection for filtering weather arts by region
- Implement sorting options for newest and oldest entries
- Update pagination to show links for each page when applicable
- Adjust the number of items displayed per page to 10

This commit enhances the user experience by allowing users to filter
and sort weather arts based on their preferences. It also improves
the pagination logic to provide more manageable navigation through
large datasets, making it easier for users to find the artworks they
are interested in.
2025-01-23 14:13:32 +08:00
3a6d247451 feat: add pagination to weather arts gallery
- Introduce ArtsController with index action
- Create index view for displaying weather arts
- Implement Kaminari for pagination functionality
- Add necessary routes for accessing arts
- Update Gemfile to include Kaminari gem
- Create views for pagination controls

This implementation enhances the Weather Arts Gallery, allowing users to view and navigate through a collection of AI-generated weather arts easily. Pagination controls have been added to improve usability.
2025-01-23 14:10:13 +08:00
5fa49d97ca fix: reduce sleep time in weather arts worker
- Change sleep duration from 1 minute to 10 seconds in
  BatchGenerateWeatherArtsWorker.

This change addresses API limitations by reducing the wait time
between job submissions, thereby increasing the efficiency of
the batch processing for generating weather arts.
2025-01-23 09:58:08 +08:00
dffac6c665 feat: modify BatchGenerateWeatherArtsWorker to use city ID
- Change BatchGenerateWeatherArtsWorker to use city ID instead of city object
- Update API endpoint to accept city ID
- Improve performance by reducing database queries

This change improves the performance of the BatchGenerateWeatherArtsWorker by reducing database queries and increasing efficiency. It is a necessary modification to ensure the worker functions correctly and efficiently.
2025-01-23 09:50:17 +08:00
c5101fb822 feat: add background processing for weather art generation
- Include Sidekiq::Worker for asynchronous task execution
- Implement condition to skip execution if weather data is up to date

These changes enable efficient weather art generation by leveraging
background processing, thereby improving overall application
performance and responsiveness.
2025-01-23 09:43:37 +08:00
c529f5fd7b refactor: update job class for weather art generation
- Change from using GenerateWeatherArtJob to GenerateWeatherArtWorker
- Maintain asynchronous job processing

This refactoring improves the clarity of the job class being used
for generating weather art and adheres to project conventions. The
change does not affect the API rate limits as the sleep duration
remains the same.
2025-01-23 09:28:31 +08:00
c1fa16c690 refactor: change weather art job processing method
- Replace synchronous job processing with asynchronous
- Ensure processing does not exceed API rate limits

This change allows for better performance by offloading the
queue management to Sidekiq, enabling more efficient
parallel processing of weather art generation. It also
prevents potential API rate limit violations by maintaining
a delay between requests.
2025-01-23 09:20:49 +08:00
08c584b85b chore: rename job classes and update Sidekiq config
- Renamed `BatchGenerateWeatherArtsJob` to `BatchGenerateWeatherArtsWorker`
- Renamed `GenerateWeatherArtJob` to `GenerateWeatherArtWorker`
- Updated Sidekiq configuration to set Redis URL and logger level
- Modified `sidekiq.yml` to use the new worker class names and added queue configurations

These changes help in aligning the class names with their purpose as
workers in Sidekiq, while also ensuring better configuration for
Redis and logging.
2025-01-22 18:47:41 +08:00
78722caeb9 chore: update gem dependencies and formatting
- Standardized quotation marks in Gemfile and Ruby files
- Improved consistency for Sidekiq and Sidekiq Scheduler
- Removed unnecessary blank line in GenerateWeatherArtWorker class

These changes ensure a consistent coding style across the project, making
it easier to read and maintain. Adjustments to the Gemfile update the
formatting without altering the functionality.
2025-01-22 17:58:46 +08:00
2bcfea30ee feat: add background job processing with Sidekiq
- Implement BatchGenerateWeatherArtsWorker to handle batch
  processing of weather art generation.
- Create GenerateWeatherArtWorker for individual weather art
  generation tasks.
- Update Dockerfile to include redis-tools for Sidekiq support.
- Modify Gemfile to add sidekiq and sidekiq-scheduler gems.
- Configure Sidekiq in initializers and set up routes for
  Sidekiq dashboard.
- Include a sidekiq.yml configuration for scheduling jobs.
- Create compose.yaml for Docker services including web,
  database, Redis, and Sidekiq workers.

These changes introduce background processing capabilities
using Sidekiq, allowing for efficient generation of weather
art through scheduled and managed job queues, optimizing
performance and scalability.
2025-01-22 17:58:25 +08:00
b5c40f2e13 fix: update Dockerfile and weather service configuration
- Added 'libpq-dev' to the packages installed in the Dockerfile
- Updated the base_uri in WeatherService to use 'dig' for safer access

These changes improve the Docker environment by ensuring that
necessary PostgreSQL development headers are available during
installation. The weather service now safely accesses the
URI from the credentials, reducing the risk of errors when
fetching nested configuration data.
2025-01-22 17:07:04 +08:00
853a1d03ce refactor: clean up ai_service code formatting
- Adjust formatting for message parameters in the chat call
- Eliminate unnecessary blank lines in generate_prompt_request method
- Ensure consistent styles for arrays and block indentation

These changes improve code readability and maintain consistency in
formatting for better maintainability without altering functionality.
2025-01-22 16:50:21 +08:00
d728d7f50e feat: add batch weather art generation jobs
- 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.
2025-01-22 16:50:00 +08:00
6e387d1a8c feat: enhance city weather card layout
- Improve image and main info section for better aesthetics
- Add gradient overlay for text readability
- Include temperature display with feel-like temperature
- Enhance city name and location styling
- Add detailed weather information metrics (Humidity, Wind, Visibility)
- Provide a backup UI for when no image is available

This update enhances the user interface of the city weather card
by improving the layout and adding more detailed weather information.
The gradient overlays and reorganized elements improve readability and
usability. Additionally, a fallback display is included for cases where
weather images are not attached, ensuring consistent design.
2025-01-22 14:51:00 +08:00
f7d295b41b feat: enhance cities filtering interface
- Introduce dropdown menus for region and country selection
- Adjust padding on title section for better layout
- Update filter navigation structure to improve UX

This commit refines the user interface for filtering cities by
allowing users to select regions and countries from dropdown
menus. The filtering options are now easier to navigate and
maintain a consistent aesthetic with adjusted padding for
better visual hierarchies.
2025-01-22 14:12:29 +08:00
da7fca139c feat: add city card component and improve index view
- Create a new partial for city card display with weather image
- Update index page to show featured weather art with gradient
- Refactor city listing layout and navigation for improved clarity

This commit introduces a new component for displaying city cards that
includes weather artwork when available. The index page has been
refactored for better visual presentation and usability. Users can
now better navigate through cities and see relevant weather data.
2025-01-22 14:10:43 +08:00
9cb1467301 feat: enhance weather arts and cities features
- Add slug column to weather_arts for friendly URLs.
- Update weather arts retrieval in the controller to use slug.
- Implement region and country filtering in cities index view.
- Optimize city queries with scopes for active status and region/country.
- Improve UI layout and design for the cities index page.

These changes allow better user experience by enabling cleaner URLs for weather arts and facilitating efficient filtering of cities based on selected regions and countries.
2025-01-22 14:04:58 +08:00
c11d10c86a feat: update city display and database schema
- Change city name display to localized name in both index and show views
- Modify schema to use bigint for certain foreign keys
- Correct country codes in seeds for accurate data representation

These changes improve the handling of city names, ensuring they are displayed in the appropriate localized format and ensuring well-typed foreign key relationships in the schema.
2025-01-21 21:29:26 +08:00
ebaf7a3f34 feat: add countries and regions management
- Implement Country and Region models
- Establish relationships between City, Country, and Region
- Update ActiveAdmin setup for managing countries and regions
- Add localization support for cities and countries in multiple languages
- Create necessary migrations to support the new schema

This update allows for better categorization of cities under their respective countries and regions, enhancing geographical structure and support for multilingual features.
2025-01-21 18:27:26 +08:00
34c05232ee chore: clean up code style and unused fixtures
- Standardize string quotes in various files for consistency.
- Remove commented-out tests from cities and weather_arts controllers to improve readability.
- Clean up admin_users and weather_arts fixture files by commenting out unused entries instead of removing them.

These changes are aimed at enhancing code readability and maintainability, ensuring that code adheres to style guidelines without removing useful comments for future reference.
2025-01-20 18:08:55 +08:00
d570f43f95 feat: add font styling and enhance city views
- Import Playfair Display and Raleway fonts for better typography
- Add a method to `City` model for fetching the latest weather art
- Revamp city index and show pages for improved layout and usability
- Update styles in the layout and main pages to enhance user experience

These changes promote visual consistency and enhance user interaction within the platform, providing a more engaging experience.
2025-01-20 18:02:28 +08:00
b9801aeb6b feat: enhance cities and weather arts display
- Update CitiesController to list all cities ordered by name
- Add latest and featured weather arts in HomeController
- Display city details, including weather art history, in Cities#show
- Expand layout with a footer and enhanced navigation
- Integrate new daisyUI plugin for improved styling

These changes improve user navigation and visual presentation on both
city and weather art pages, making it easier to browse and view
information. The introduction of daisyUI also modernizes the UI with
consistent design elements.
2025-01-19 22:08:05 +08:00
e5743a5e3f feat: add friendly_id for cities and weather arts
- Integrate 'friendly_id' gem for sluggable functionality in City model
- Create ActiveAdmin resources for managing cities and weather arts
- Implement controller logic for cities
- Add database migrations for cities and weather arts creation
- Seed database with sample data for testing
- Create initial test cases for controllers and models

This commit enhances the application's URL handling by allowing friendly URLs for cities and weather arts. The addition of ActiveAdmin resources facilitates easier management through a web interface.
2025-01-19 12:21:00 +08:00
8517905b68 init with rails8 + active-admin 2025-01-19 01:13:59 +08:00