Commit Graph

19 Commits

Author SHA1 Message Date
0e476b546d feat: add locking mechanism to batch task worker
Some checks failed
Docker Dev / docker (push) Has been cancelled
CI / scan_ruby (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
Docker Main / docker (push) Has been cancelled
- Introduce a Redis-based lock to prevent concurrent execution of
  batch generation tasks.
- Set a TTL of 300 seconds for the lock to ensure it is released
  after a timeout.
- Add logging for situations where a task is already in progress.

This enhancement ensures that batch tasks do not overlap, which can
lead to data inconsistencies and resource contention. The locking
mechanism improves the reliability of the batch processing system.
2025-02-22 15:41:42 +08:00
bd42833953 feat: add translatable name module for countries and regions
- Introduced `TranslatableName` module to allow for
  localized names for `Country` and `Region` models.
- Updated views to display `localized_name` instead of
  `name` for improved internationalization.
- Refactored JSON serialization for `translations` attribute.
- Enhanced localization support by adding new languages:
  Japanese and Korean, with updated locale files.
- Removed outdated English and Chinese locales for countries
  and regions to clean up the codebase.
2025-02-21 23:46:25 +08:00
d37d06c0d7 fix: add country code assignment in city creation
- Include assignment of country code when creating a city
- Ensure that all relevant geographical data is accounted for during
  the city creation process

This change addresses a missing assignment of the country code for new
city records, ensuring that instances are complete and accurate.
2025-02-11 17:59:23 +08:00
1545b33539 feat: add user authentication with devise
- Integrate Devise for user authentication
- Create User model and necessary views
- Implement email confirmation and password reset functionality
- Add routing for user sign-up and login
- Customize error messages display

This commit initiates user authentication in the application
using the Devise gem. It includes user registration, login,
password reset, and email confirmation features. Additionally,
the necessary views and mailer templates are included to
support these functionalities. This enhances the security
and usability of the application by allowing users to create
accounts and manage their passwords effectively.
2025-02-11 14:45:23 +08:00
92ec81b152 feat: add devise for user authentication
- Include 'devise' gem for user management
- Update database access URLs in configurations
- Refactor schema types from bigint to integer for resource and author IDs
- Enhance geo synchronization by updating region and subregion handling

These changes are aimed at improving the user management functionality while ensuring efficient data handling and connections for production environment.
2025-02-11 11:46:15 +08:00
90c491637b refactor: simplify country retrieval logic
- Replace verbose conditional checks with a ternary operator
- Use 'find_by!' for better error handling if country not found
- Maintain the functionality of state creation associated with the country
2025-02-11 10:50:08 +08:00
24597e6320 refactor: update city sync logic with country and state
- Replace country name lookup with country code lookup
- Replace state name lookup with state code lookup
- Change city creation to ensure country association

This update modifies the existing logic for synchronizing city data to
use country and state codes instead of names. This aids in ensuring
more robust data integrity by relying on unique identifiers.
2025-02-11 10:35:41 +08:00
b4eac06227 refactor: streamline geo data syncing process
- Remove unnecessary debug output for country syncing.
- Improve country determination logic by adding checks for
  both country code and country name.
- Ensure state records are associated with the correct
  country ID post-refactor.

These changes enhance the clarity and efficiency
of the geo data synchronization code, making it easier to
maintain and reducing the risk of errors during data
syncing.
2025-02-11 10:30:25 +08:00
febee58d0a fix: correct state syncing logic
- Change output to include country name during state syncing
- Update record creation from `find_or_initialize_by!` to `find_or_create_by!`

This fix ensures that when syncing state data, the output provides
better context by showing the associated country name, and it also
ensures that states are created if they do not already exist, thus
eliminating potential issues with duplicate state entries.
2025-02-11 10:18:24 +08:00
f67ff92ba8 fix: improve country creation logic
- Refactor the country creation process to use a block for setting
  the name attribute.
- Ensure that the name is set explicitly when a new country is
  created with the appropriate ISO code.

This change optimizes the way country records are created and
ensures the name is always correctly assigned during the
creation process.
2025-02-11 10:05:08 +08:00
d3dae4f079 fix: ensure creation and updating of geo data
- Replace `find_or_create_by` and `find_or_initialize_by` with `find_or_create_by!` and `find_or_initialize_by!` for better error handling.
- Use the `update!` method instead of `update` to raise exceptions on failure.
- These changes improve the reliability of geographic data synchronization by ensuring failures are not silently ignored and facilitate easier troubleshooting.
2025-02-11 09:48:54 +08:00
29ad6be241 refactor: simplify region creation and update code attribute
Some checks are pending
Docker / docker (push) Waiting to run
CI / scan_ruby (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
- Change from find_or_initialize_by to find_or_create_by for
  regions.
- Set region code to the name instead of nil.

This refactor reduces complexity in how regions are created and
ensures the code attribute is properly populated with the
region's name, enhancing data consistency.
2025-02-10 18:01:41 +08:00
97330fef91 fix: update region name and clear code
- Update region name with data from the input
- Set code to nil to reset any previous values
- Preserve other attributes like translations, flag, and wiki_data_id

This change ensures that region data is updated correctly with the
provided input while eliminating any previous code settings that may
no longer be relevant.
2025-02-10 17:37:11 +08:00
e774b3e736 fix: correct subregion initialization by name
- Change the method of finding or initializing subregions to use
  the name attribute instead of the id.
- This improves accuracy when synchronizing subregion data, as it
  ensures that subregions are correctly matched by name.
- Eliminates potential issues with duplicate IDs if they happen
  to be reused across different data sources.
2025-02-10 17:21:29 +08:00
bafb889144 refactor: change region identification method
- Update the region lookup to use `name` instead of `id`
- This change allows for more flexible region identification
- Improves alignment with potential data structure changes
2025-02-10 17:19:58 +08:00
27100aec24 fix: improve country creation logic
- Change method from find_or_create_by to find and check for nil
- Initialize a new Country object only if none exists

This fix addresses the potential issue where a country
is being unnecessarily created instead of found, improving
the efficiency of the country data synchronization process.
This change also adds clarity to the method's intent by
clearly separating the find and the initialization logic.
2025-02-10 17:07:48 +08:00
3f1e8892f9 chore: update AWS SDK dependencies and improve schema
- Downgraded `aws-sdk-s3` to version 1.170 and updated
  `aws-sdk-core` to 3.211 to maintain compatibility with
  existing code.
- Updated various column types in the database schema
  from `integer` to `bigint` to handle larger values and
  improve data integrity.
- Modified the `sync_geo_data.rake` task to use
  `find_or_create_by` for `Country`, improving the logic
  for ensuring unique countries based on ISO code.

These changes enhance dependency management and improve
schema robustness while maintaining functionality.
2025-02-10 14:43:34 +08:00
652107d0ee migrate with countries_states_cities_db 2025-02-08 17:42:50 +08:00
8517905b68 init with rails8 + active-admin 2025-01-19 01:13:59 +08:00