Commit Graph

54 Commits

Author SHA1 Message Date
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
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
2d81dd91e7 feat: activate cities in seed files
- Update active status of various cities from false to true
- Ensures that all seeded cities are now enabled and available for usage

This change activates previously inactive cities in the seed files, which
facilitates their accessibility in subsequent deployments and testing.
The modification was made across numerous city seed files to ensure a
consistent state where all cities are now marked as active, improving
the readiness of the application.
2025-01-22 17:00:27 +08:00
2ab495897d chore: update Dockerfile to install libpq5
- Add libpq5 to the list of installed packages for
  database connections.
- Remove libpq-dev from the list as it is no longer
  necessary for the build process.

These adjustments enhance the Docker image configuration,
ensuring the application can connect to PostgreSQL databases
without unnecessary build dependencies.
2025-01-22 16:57:54 +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
be7856935f
Merge pull request #1 from songtianlun/dependabot/bundler/selenium-webdriver-4.28.0
chore(deps-dev): bump selenium-webdriver from 4.27.0 to 4.28.0
2025-01-22 09:45:08 +08:00
e70763dbe0 chore: update workflow name for Docker build
- Change workflow name from 'Build and Publish Docker Image' to 'Docker'

This change simplifies the workflow name for better readability and
identification in the CI/CD pipeline.
2025-01-22 09:39:04 +08:00
f83600412b chore: update docker workflow to include tags
- Add support for tagging workflow triggers on pushes
- Include version tags following the pattern 'v*'

This change enhances the Docker workflow by allowing the CI/CD
pipeline to respond to version tags, which is beneficial for
versioned releases and better management of deployment processes.
2025-01-22 09:37:35 +08:00
93b24ff50c chore: update Dockerfile to include libpq-dev
- Add libpq-dev to the list of packages installed for the build
- Ensure that the environment has the necessary dependencies

This change updates the Dockerfile to include the libpq-dev package,
which is required for compiling certain gem dependencies. The inclusion
of this package improves the compatibility of the environment with
database-related gems during the build process, ensuring a smoother
setup for development and deployment.
2025-01-22 09:29:37 +08:00
c9aef3ddfe build: update Docker workflow for versioning
- Add checkout step to retrieve full git history
- Introduce a step to get the current version of the project
- Modify login step to use the actor's username instead of a constant
- Update the tags to use dynamic versioning in Docker image push

These changes improve the Docker workflow by ensuring that the
correct version tag is used when building and pushing Docker
images. The modified steps enhance traceability and allow
the workflow to handle versioning accurately based on current
git tags, addressing the need for specific version control in
the images produced.
2025-01-22 09:23:59 +08:00
48f3da8913 chore: update Docker workflow for tagging
- Remove unnecessary steps for version extraction
- Simplify tag assignment using environment variables

This update cleans up the Docker workflow by eliminating steps
that were not crucial for the tagging process. The tagging
is now done directly with the repository name, reducing redundancy
and improving clarity in the workflow configuration.
2025-01-22 09:19:28 +08:00
a988c49ae0 chore: update docker tags formatting
- Change Docker tags configuration to be multiline
- Improve clarity and maintainability of the workflow

This change enhances the readability of the tags in the
Docker workflow, facilitating easier updates and understanding
of the tagging process.
2025-01-22 09:07:52 +08:00
1ab860c739 chore: fix output redirection in docker workflow
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
Build and Publish Docker Image / docker (push) Waiting to run
- Corrected syntax errors in output redirection
- Ensured that LATEST_TAG and VERSION_TAG are set correctly in the GitHub Actions output

These changes fix an issue where the command was improperly formatted,
which could lead to unexpected behavior during the workflow execution.
2025-01-22 01:05:13 +08:00
24cbf13a26 feat: enhance Docker workflow version tagging
- Store latest and version tags in variables
- Clean up output by using variables for tags

This update improves the clarity of the tagging process in the
Docker workflow configuration. The tags are now stored in
variables for better manageability and consistency in
environment output.
2025-01-22 01:02:22 +08:00
5bb91f16fd fix: correct LATEST_TAG output variable
- Remove extraneous dollar sign from LATEST_TAG
- Ensure correct evaluation during workflow execution

This fix resolves an issue that could cause the incorrect
setting of the LATEST_TAG environment variable in the
GitHub Actions workflow, ensuring proper deployment tagging.
2025-01-22 00:58:37 +08:00
04595824e6 feat: configure docker image prefix
Update Docker workflow to include image prefix in version and latest tag

Change the Docker image prefix in the GitHub workflow to include the registry, username and image name.
Update the environment variables to use the new format for the image prefix.
2025-01-22 00:56:58 +08:00
2b4275055c feat: update fetch-depth in docker workflow
- Update fetch-depth in Docker workflow configuration
- No additional dependencies added

This change updates the fetch-depth setting in the GitHub Actions Docker workflow. This ensures that we get the full Git history for the code checkout. There are no additional dependencies added to this change.
2025-01-22 00:51:55 +08:00
0f9b4efc80 chore: add checkout step in docker workflow
- Include checkout code step using actions/checkout@v3
- Set fetch-depth to 0 to retrieve the full git history

This change ensures that the workflow has access to the complete
commit history, which may be necessary for certain operations
within the Docker build process.
2025-01-22 00:51:08 +08:00
ec2c92e6c9 chore: update Docker workflow to use secrets
- Change hardcoded Docker Hub username to use secrets
- Update workflow to securely reference DockerHub credentials

This update enhances the security of the GitHub Actions workflow
by using secrets instead of exposing sensitive information
in the codebase. This ensures that the Docker Hub username is
kept private and reduces the risk of accidental exposure.
2025-01-22 00:47:33 +08:00
54133b2f87 feat: add GitHub Actions workflow for building and publishing Docker image
- Add Docker login step
- Set up QEMU
- Set up Docker Buildx
- Build and push Docker image

This feature allows for automated building and publishing of Docker images to Docker Hub. It includes proper setup of QEMU and Docker Buildx for cross-platform compatibility and efficient image building.
2025-01-22 00:45:11 +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
dependabot[bot]
e2e5e38a7d
chore(deps-dev): bump selenium-webdriver from 4.27.0 to 4.28.0
Bumps [selenium-webdriver](https://github.com/SeleniumHQ/selenium) from 4.27.0 to 4.28.0.
- [Release notes](https://github.com/SeleniumHQ/selenium/releases)
- [Changelog](https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES)
- [Commits](https://github.com/SeleniumHQ/selenium/compare/selenium-4.27.0...selenium-4.28.0)

---
updated-dependencies:
- dependency-name: selenium-webdriver
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-21 06:36:52 +00:00
ac199af963 style: standardize quoting for pg gem
- Changed single quotes to double quotes for the 'pg' gem in the production group of the Gemfile.

This change enhances consistency in the Gemfile by standardizing the quoting style.
2025-01-21 09:11:00 +08:00
5fd9573cf2 chore: add pg gem for production environment
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
- Introduced the 'pg' gem for PostgreSQL support in the production
  environment.
- Updated Gemfile to include it in the production group.
- Corresponding update in Gemfile.lock to ensure version 1.5.9 is
  used.

This change prepares the application to use PostgreSQL as the
primary database in production, which is essential for running
production-grade applications effectively.
2025-01-20 18:47:06 +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
a533390356 feat: add weather art records for Guangzhou
- Update weather date for existing record to 5 days ago
- Add new weather art record for 2 days ago with relevant details
- Include image attachment for the new weather art

This commit adds a second weather art record for Guangzhou reflecting the
weather conditions from 2 days ago, along with relevant data including
humidity, wind speed, and an updated visual representation.
2025-01-20 17:37:24 +08:00