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

feat(location): add continent method #3162

Merged
merged 12 commits into from
Oct 12, 2024

Conversation

joscha
Copy link
Contributor

@joscha joscha commented Oct 8, 2024

Adds a new function to the location module that generates the name of a random continent.

@joscha joscha requested a review from a team as a code owner October 8, 2024 21:49
Copy link

netlify bot commented Oct 8, 2024

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 2ce8d00
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/670a6ce4eb500e000854eca7
😎 Deploy Preview https://deploy-preview-3162.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.97%. Comparing base (033c23b) to head (2ce8d00).
Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3162   +/-   ##
=======================================
  Coverage   99.96%   99.97%           
=======================================
  Files        2797     2798    +1     
  Lines      227777   227793   +16     
  Branches      952      958    +6     
=======================================
+ Hits       227694   227732   +38     
+ Misses         83       61   -22     
Files with missing lines Coverage Δ
src/definitions/location.ts 100.00% <ø> (ø)
src/locales/en/location/continent.ts 100.00% <100.00%> (ø)
src/locales/en/location/index.ts 100.00% <100.00%> (ø)
src/modules/location/index.ts 100.00% <100.00%> (+0.94%) ⬆️

... and 1 file with indirect coverage changes

@import-brain import-brain added c: feature Request for new feature p: 1-normal Nothing urgent m: location Something is referring to the location module labels Oct 9, 2024
@import-brain import-brain added this to the v9.x milestone Oct 9, 2024
Copy link
Member

@ST-DDT ST-DDT left a comment

Choose a reason for hiding this comment

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

Please note, that we (usually) require an issue first.

https://github.com/faker-js/faker/blob/next/CONTRIBUTING.md

src/modules/location/index.ts Outdated Show resolved Hide resolved
@joscha
Copy link
Contributor Author

joscha commented Oct 9, 2024

Please note, that we (usually) require an issue first.

Do we need that in this case? It feels like an extremely simple case. If we don't want it, I can close the PR, no hurt feelings, if we do want it there is not a lot more background to it :)

See #3164

@joscha joscha requested a review from ST-DDT October 9, 2024 11:22
@matthewmayer
Copy link
Contributor

I feel this is such a harmless addition we can probably skip the usual

  • make issue
  • wait for 10 upvotes
  • implement

I can't really think of any way this api could be extended. And it's a trivial amount of data.

We have spent a long time improving the code and processes. I think in various 8.x releases we can take advantage of that and add some "low-hanging fruit" methods.

@ST-DDT
Copy link
Member

ST-DDT commented Oct 9, 2024

In this case it is probably fine (thats why I put the usually in parethesis).

One lesson we learned for sure is that lot location stuff seems simple, but the usecases vary a lot. Some people might need only the name, others might only need the code, and some need both related to each other (e.g. countries).

I did a quick google search and found this list of continent codes.

What do you/the others think?

@joscha
Copy link
Contributor Author

joscha commented Oct 9, 2024

I've never heard about continent codes before, but it makes sense there would be some.

Just one note: the two data sources above have continents like the UN interprets them, see here. This means that for example they have Oceania instead of Australia (my data source).
From Wikipedia:

Oceanic islands are occasionally grouped with a nearby continent to divide all the world's land into geographical regions. Under this scheme, most of the island countries and territories in the Pacific Ocean are grouped together with the continent of Australia to form the geographical region Oceania.[2]

I am not hooked on either; happy to change it to whatever fits best with the rest of faker's data, as long as we have a list of continents in the end.

@matthewmayer
Copy link
Contributor

I have never heard of the continent codes before (or seen them in use in any software)

So I think just the names are fine.

@ST-DDT ST-DDT linked an issue Oct 9, 2024 that may be closed by this pull request
Copy link
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

because country is also just string[] right now, I would suggest to do the same with continent for now

test/modules/location.spec.ts Show resolved Hide resolved
src/locales/en/location/continent.ts Outdated Show resolved Hide resolved
test/modules/location.spec.ts Outdated Show resolved Hide resolved
src/definitions/location.ts Outdated Show resolved Hide resolved
@joscha joscha requested a review from ST-DDT October 11, 2024 08:00
@xDivisionByZerox
Copy link
Member

I'll merge this PR since it has sufficent approvals.

Thank you for contribution @joscha. Your change will be included in the upcoming version 9.1.0 of Faker.

@xDivisionByZerox xDivisionByZerox merged commit 4056ab0 into faker-js:next Oct 12, 2024
23 checks passed
@joscha joscha deleted the joscha/location/continent branch October 12, 2024 13:47
@joscha
Copy link
Contributor Author

joscha commented Oct 12, 2024

Thank you all for your reviews and help to get this in.

@xDivisionByZerox xDivisionByZerox mentioned this pull request Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: feature Request for new feature m: location Something is referring to the location module p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

faker.location.continent for generating random (real) continents
6 participants