Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2] Add normalised location to Company resource #51

Merged
merged 1 commit into from
Sep 8, 2024

Conversation

CalvinWalzel
Copy link
Owner

@CalvinWalzel CalvinWalzel commented Aug 25, 2024

This pull request introduces significant changes to the Company model and its associated frontend and backend components to include geographical information. The most important changes include adding new models for City, Region, Country, and Continent, updating the Company model and serializer to include these new relationships, and modifying the frontend to display this information.

Backend Changes:

  • Models and Associations:

    • Added new models: City, Region, Country, and Continent with appropriate associations and validations. (app/models/city.rb, app/models/region.rb, app/models/country.rb, app/models/continent.rb) [1] [2] [3] [4]
    • Updated Company model to include associations with City, Region, Country, and Continent. (app/models/company.rb)
  • Serializers:

    • Updated CompanySerializer to include address and geographical information. (app/serializers/company_serializer.rb)
    • Added GeoFragmentSerializer for serializing geographical fragments. (app/serializers/geo_fragment_serializer.rb)
  • Database Migrations:

    • Created migration files for new models and updated the schema to reflect these changes. (db/migrate/20240823144658_create_continents.rb, db/migrate/20240823144705_create_countries.rb, db/migrate/20240823144711_create_regions.rb, db/migrate/20240823144715_create_cities.rb, db/migrate/20240823144728_add_city_to_companies.rb, db/schema.rb) [1] [2] [3] [4] [5] [6] [7] [8]

Frontend Changes:

  • Components and Props:
    • Updated Company interface to include address and geographical information. (app/frontend/types/company.ts) [1] [2]
    • Modified Show component to display the company's address and geographical information. (app/frontend/pages/companies/show.tsx) [1] [2]
    • Added a new column for location in the Index component. (app/frontend/pages/companies/index.tsx)

Controller Changes:

  • CompaniesController:
    • Refactored CompaniesController to use a new company_scope method for including geographical associations. (app/controllers/companies_controller.rb)

@CalvinWalzel CalvinWalzel self-assigned this Sep 7, 2024
@CalvinWalzel CalvinWalzel added the v2 label Sep 7, 2024
@CalvinWalzel CalvinWalzel marked this pull request as ready for review September 7, 2024 13:32
Copy link
Collaborator

@GittavanderPol GittavanderPol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! :)


private

def company_scope
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@CalvinWalzel CalvinWalzel merged commit 445c1c5 into version-2 Sep 8, 2024
4 checks passed
@CalvinWalzel CalvinWalzel deleted the v2/company-location branch September 8, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants