Commit Graph

86 Commits

Author SHA1 Message Date
f6270b1ad4 feat: add weather icons and update city view
- Introduce `weather_description_icon` and `weather_stat_icon`
  helper methods for displaying SVG icons based on weather
  conditions and statistics.
- Enhance the city show view by using these icons to display
  visual weather information such as temperature, wind, humidity,
  visibility, pressure, and cloud cover.
- Optimize the visual styling and layout of the weather stats
  and cards for better user experience.
2025-01-24 10:01:43 +08:00
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
dd6bb9972c feat: implement ads.txt configuration
- Add ads.txt configuration file
- Update public/ads.txt with Google AdMob publisher ID

This feature allows us to set up Google AdMob in our app and earn revenue from ads.
It includes proper configuration of the ads.txt file for future ad networks.
2025-01-24 09:14:13 +08:00
23fc14af59 style: format priority values for consistency
- Clean up the seed file for cities in China
- Ensure all priority values have a consistent formatting style

This change enhances the readability of the data seeding code without altering the underlying logic or functionality of the application.
2025-01-24 09:09:57 +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
2cd23a6047 fix: update ownership permissions in Dockerfile
- Added 'public' directory to the chown command to ensure the
  proper ownership for runtime files.
- This change enhances the security by ensuring that all
  necessary directories are owned by the designated non-root
  user.

The previous behavior did not account for the 'public'
directory, which could lead to permission issues at runtime.
2025-01-23 19:53:50 +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
6544f0247c chore: update robots.txt for better indexing
- Add disallow rules for /admin/ to prevent indexing
- Update sitemap URL to point to the correct domain

These changes improve site indexing by ensuring that sensitive
admin pages are not accessible to search engine crawlers
and updating the sitemap to reflect the accurate URL, helping
discovery and SEO efforts.
2025-01-23 19:03:00 +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
2759646145 chore: update docker compose file
- Update compose.yaml to pull policy: always for production environment
- Added RAILS_ENV environment variable for production

Changes impact the overall system functionality by ensuring containers are always pulled from the latest images, and provide clear environment variables for the production environment.
2025-01-23 17:44:03 +08:00
665f6f29b6 refactor: change Sidekiq route to admin/tasks
- Update route for Sidekiq web interface from '/sidekiq'
  to '/admin/tasks'

This change improves the coherence of the application's routing
by placing the Sidekiq interface under a more descriptive
namespace. It consolidates admin-related tasks under a common
path, enhancing the organization of the routing structure.
2025-01-23 17:34:45 +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
b3089856c2 chore: update docker network configuration
- Change network from 'net1' to 'dokploy-network'
- Make 'dokploy-network' an external network
- Update references in multiple services

This update modifies the docker-compose configuration to
utilize an external network named 'dokploy-network' instead
of the previously defined 'net1'. This change is intended
to improve network management and integration with existing
infrastructure.
2025-01-23 10:49:53 +08:00
ccb48a387b feat: add network configuration to Docker compose
- Define a custom network 'net1' for services
- Attach services to 'net1' network
- Ensure connectivity between application components

This commit enhances the Docker Compose setup by introducing a
custom network. This isolation can help manage service
dependencies better and improve communication between services,
establishing clearer boundaries. It simplifies networking
configuration and lays the groundwork for further scaling
if needed.
2025-01-23 10:44:37 +08:00
e1f9118ead chore: remove version from compose file
- Removed the version declaration from the compose.yaml file.

This change simplifies the configuration by removing a version number,
allowing Docker Compose to use the latest compatible version. This
change does not impact the functionality of the services defined in
this file.
2025-01-23 10:31:50 +08:00
af95c2e55f chore: update environment variables in compose.yaml
- Replace hardcoded DATABASE_URL and RAILS_MASTER_KEY with
  environment variables.
- Change POSTGRES_PASSWORD to utilize an environment
  variable instead of a hardcoded value.

These changes enhance security by ensuring sensitive
information is not exposed in the configuration files,
allowing for better practices in managing environment
variables.
2025-01-23 10:22:07 +08:00
91e62234b4 chore: comment out port configuration for web service
- Disabled port mapping for the web service in the Docker Compose file
- This may affect how the application is accessed outside of the container
- The decision to comment out the ports could be for environmental reasons or to avoid port conflicts
2025-01-23 10:19:27 +08:00
6eb8d10965 chore: update port mapping in docker-compose 2025-01-23 10:18:49 +08:00
97d7930daa chore: update redis data volume path
- Changed Redis data volume path from '../daw_data/redis' to '../taw_data/redis'.

This update reflects a restructuring in the project directory for better
data organization and may require corresponding adjustments in other
configuration files to ensure data consistency.
2025-01-23 10:13:45 +08:00
a15bc349a2 feat: update docker compose configuration
- Update PostgreSQL data directory to point to taw_data/pg
- Update Redis data directory to point to daw_data/redis

This change updates the Docker compose file to use different data directories for PostgreSQL and Redis. It improves the overall organization and clarity of the configuration.
2025-01-23 10:11:39 +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
fd6292a81e chore: update Docker workflow configuration
- Simplify step definitions by removing unnecessary
  empty lines.
- Ensure compatibility with Docker Hub through the
  addition of a comment to clarify the usage of the
  REGISTRY variable.

These changes enhance the readability of the workflow file
without affecting its functionality. They make the CI/CD
pipeline clearer for future contributors by simplifying
structure and providing contextual information.
2025-01-23 09:36: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
2d5521c3dc chore: adjust sidekiq worker schedule
- Update `BatchGenerateWeatherArtsWorker` cron job to run every 1 hour
- This change will result in weather arts being generated more frequently
2025-01-23 09:19:23 +08:00
799dfc18ed fix: update weather fetch timing to days
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
- Changed 'last_weather_fetch' and 'last_image_generation'
  from 10.hours.ago to 10.days.ago for various cities
- Affects seed data for cities in multiple countries, including:
  - Australia
  - Bangladesh
  - Brazil
  - Canada
  - China
  - Egypt
  - France
  - Germany
  - India
  - Japan
  - Mexico
  - Nigeria
  - Pakistan
  - Russia
  - Saudi Arabia
  - Singapore
  - South Korea
  - Thailand
  - Turkey
  - UK
  - USA
  - Vietnam

This change ensures that the timestamps reflect a more refined time range for when last weather data was fetched, possibly to enhance performance or consistency in application behavior.
2025-01-23 01:50:04 +08:00
a2c75ba3c2 feat: cache Docker layers and update dependencies
- Removed unnecessary queue configurations from Sidekiq configuration
- Added 'whenever' gem and its necessary dependencies for adding cron jobs
- Updated Docker workflow to cache Docker layers using actions/cache

This update improves the efficiency of CI/CD pipelines by caching Docker layers, which will help in reducing the time taken for the build process. Additionally, the changes in the Gemfile and the config/sidekiq.yml configuration will enable the project to run cron jobs for tasks like generating weather arts.
2025-01-23 01:37:47 +08:00
e9095ece6e feat: improve Sidekiq scheduling configuration
- Enable dynamic scheduling only if the schedule file exists
- Update the sidekiq.yml to include a new job for batch generation
- Define a cron schedule for the new job to run every 2 hours

This update allows Sidekiq to conditionally enable its scheduler and
introduces a new job that processes weather art batches every two
hours. The change enhances the job management and scheduling
dynamics in the application.
2025-01-23 01:07:39 +08:00
c20ff296eb fix: update Active Job queue adapter to Sidekiq
- Comment out previous queue adapter setting for Solid Queue
- Set Active Job queue adapter to Sidekiq for better performance

This change updates the Active Job queue adapter from Solid Queue to
Sidekiq. This adjustment is intended to improve job processing
performance and reliability in production environments. The previous
adapter setting will be retained as a comment for reference.
2025-01-23 00:51:56 +08:00
f74f34ce82 chore: update admin user creation for seeds
- Remove environment condition for admin user creation

This change simplifies the admin user creation in the seeds file by
removing the conditional check for the development environment.
As a result, the admin user will be created regardless of the
environment, which may need to be addressed to avoid unintended
consequences in production setups.
2025-01-23 00:40:42 +08:00
a6cea6b80d chore: setup admin user
- Create admin user with email 'admin@example.com' and password 'password' for development environment
This change allows for easier development and testing by providing a default admin user.
2025-01-23 00:40:19 +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
607fc9e8b8 chore: update asset precompilation command
- Change the precompilation command to include RAILS_BUILD=1
- This modification allows for environment-specific builds without altering the existing secret handling

This update enhances the flexibility of the asset precompilation process during deployment while maintaining the required application security measures.
2025-01-22 17:29:43 +08:00
494ae40088 chore: update storage configuration for production
- Change active storage service to use `:build` or `:amazon`
- Added a new `build` service for local disk storage

This update allows for better flexibility in managing file
storage based on the environment. The configuration now checks
the `RAILS_BUILD` environment variable to decide on the
storage service, making it easier to handle local testing and
production deployments without manual adjustments.
2025-01-22 17:26:06 +08:00
3748ea5215 chore: update AWS region defaults in storage config
- Change default region for amazon_dev to 'wnam'
- Change default region for amazon to 'wnam'

This commit updates the storage configuration for AWS S3 by
setting the default region to 'wnam' for both development
and production environments. The change ensures that a valid
region is used even when the environment variable is not set.
This is a preparatory step for deployments needing a specific
region if the configuration is incomplete.
2025-01-22 17:17:05 +08:00
fd910fb469 fix: update job scheduling interval
- Change job execution frequency from once every hour to every two hours.
- Ensure the `BatchGenerateWeatherArtsJob` runs as intended without unnecessary frequency.

This change addresses performance concerns by reducing the load on the system caused by frequent job executions.
2025-01-22 17:08:46 +08:00