- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- 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.
- 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.