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(person): add zodiacSign() #182

Merged
merged 3 commits into from
Nov 7, 2022
Merged

Conversation

luciferreeves
Copy link
Contributor

@luciferreeves luciferreeves commented Jan 17, 2022

This PR adds the functionality of generating random zodiac signs and birthdate

New Functions:

  • faker.date.birthdate() (Moved to a separate PR)
  • faker.zodiac.sign()

Usage:

faker.date.birthdate():

// generates a random birthdate of a person aged between 18 and 80
console.log(faker.date.birthdate()) // 1970-12-22T05:00:00.000Z

// generates a random birthdate of a person, between two years
console.log(faker.date.birthdate({ min: 1990, max: 2000 });) // 1992-03-06T05:00:00.000Z

you can also pass a mode to the birthdate object. mode can be 'age' or 'year'

// generates a random birthdate of a person, between two years
console.log(faker.date.birthdate({ min: 1990, max: 2000, mode: 'year' });) // 1992-03-06T05:00:00.000Z

// generates a random birthdate of a person, between two ages
console.log(faker.date.birthdate({ min: 4, max: 5, mode: 'age' });) // 2017-06-08T04:00:00.000Z

faker.zodiac.sign():

// returns a random zodiac sign
console.log(faker.zodiac.sign()) // Leo

// takes optional 'birthday' parameter, if provided returns the zodiac sign for the given birthday
console.log(faker.zodiac.sign('1997-12-20')) // Sagittarius

Unit tests for both the functions added.

Sorry for the repeated commit found later. Its a refactor, but I have some zsh extensions which automatically complete commands in the terminal and it picked up on the last commit message.

Closes #175

@netlify
Copy link

netlify bot commented Jan 17, 2022

✔️ Deploy Preview for vigilant-wescoff-04e480 ready!

🔨 Explore the source changes: 652f568

🔍 Inspect the deploy log: https://app.netlify.com/sites/vigilant-wescoff-04e480/deploys/61e4c13c519e350007f8a5c9

😎 Browse the preview: https://deploy-preview-182--vigilant-wescoff-04e480.netlify.app

@Shinigami92 Shinigami92 added this to the v6.1.0 milestone Jan 17, 2022
@Shinigami92 Shinigami92 added the p: 1-normal Nothing urgent label Jan 17, 2022
@import-brain import-brain requested a review from a team January 18, 2022 21:03
@Shinigami92
Copy link
Member

I will review this after 6.0.0 was released

@pkuczynski
Copy link
Member

I would expect faker.date.birthday to have a bit different signature:

faker.date.birthday(age: number, refDate?: string | Date)
faker.date.birthday(options: { min: number, max: number }, refDate?: string | Date)

So instead of providing a year, I would rather expect to provide an age...

@luciferreeves
Copy link
Contributor Author

luciferreeves commented Jan 26, 2022

I would expect faker.date.birthday to have a bit different signature:

faker.date.birthday(age: number, refDate?: string | Date)
faker.date.birthday(options: { min: number, max: number }, refDate?: string | Date)

So instead of providing a year, I would rather expect to provide an age...

I have added a mode option to the faker.date.birthday object. Please take a look at the updated description.

@ST-DDT
Copy link
Member

ST-DDT commented Jan 26, 2022

Please migrate all js files to ts.

@pkuczynski
Copy link
Member

Please migrate all js files to ts.

I think it was an accidental commit of lib/* files...

@luciferreeves
Copy link
Contributor Author

I removed the older js files

@ST-DDT
Copy link
Member

ST-DDT commented Jan 27, 2022

Have the examples files been committed intentionally?

@luciferreeves
Copy link
Contributor Author

I didn't notice the example files were removed from the newer structure of the repo. I removed them from this PR too.

src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
test/date.spec.ts Outdated Show resolved Hide resolved
src/zodiac.ts Outdated Show resolved Hide resolved
@luciferreeves luciferreeves requested a review from ST-DDT January 27, 2022 15:14
src/zodiac.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
test/date.spec.ts Outdated Show resolved Hide resolved
@luciferreeves
Copy link
Contributor Author

Everything that was suggested is added. Please check

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.

One last part, otherwise it looks good to me.
Thanks for your contribution.
Please note that this is scheduled for 6.1 so it might take a while before this gets merged.

src/date.ts Outdated Show resolved Hide resolved
Copy link
Contributor Author

@luciferreeves luciferreeves left a comment

Choose a reason for hiding this comment

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

Okay, everything is fixed now. Instead of datatype.number() as suggested, I used this.faker.datatype.float({ min: 0, max: 1, precision: 0.0000000000000001 }) to replicate the Math.random() behavior.

@luciferreeves luciferreeves requested a review from ST-DDT January 28, 2022 16:58
@pkuczynski
Copy link
Member

General comment: you should separate zodiac signs and birthday into two separate PR, as they are totally independent.

@luciferreeves
Copy link
Contributor Author

General comment: you should separate zodiac signs and birthday into two separate PR, as they are totally independent.

@pkuczynski Maybe from next time, I will target smaller issues/PRs. Too many commits have gone in this PR and it would be hard to undo those changes, split branches and redo again.

@pkuczynski
Copy link
Member

pkuczynski commented Jan 28, 2022

@pkuczynski Maybe from next time, I will target smaller issues/PRs. Too many commits have gone in this PR and it would be hard to undo those changes, split branches and redo again.

You don't need to split branches. Just create a new one and copy 3 files from this PR regarding date, create new PR from them, and delete in this PR. We don't need the whole commit/review history. This way you increase a chance that one of them will be merged faster.

@luciferreeves
Copy link
Contributor Author

luciferreeves commented Jan 28, 2022

I see. Although, I still fail to see the usage of 2 PRs now since this once is almost completed review and is targeted for v6.2 and won't be merged anytime soon either. A lot of PRs target multiple features/bugs and doing multiple things in the same PR is not something new. However, I will try to split the PRs if I get time.

@Shinigami92 Shinigami92 changed the title feat(zodiac): add new module feat(person): add westernZodiacSign() Oct 13, 2022
@Shinigami92
Copy link
Member

We might want to discuss in team if we want just zodiacSign that accepts 'western' | 'chinese' or if we want two separate methods 🤔

@Shinigami92 Shinigami92 added the s: needs decision Needs team/maintainer decision label Oct 13, 2022
@import-brain
Copy link
Member

import-brain commented Oct 13, 2022

We might want to discuss in team if we want just zodiacSign that accepts 'western' | 'chinese' or if we want two separate methods 🤔

I would prefer just having zodiacSign that accepts 'western' | 'chinese' or 'western' | 'eastern'.

@Shinigami92 Shinigami92 removed the s: on hold Blocked by something or frozen to avoid conflicts label Oct 16, 2022
@Shinigami92
Copy link
Member

@luciferreeves if you like to, you can already at least move the method to the person module now after a rebase

If you do not have time, please let me know and I can take this PR over

@ST-DDT
Copy link
Member

ST-DDT commented Oct 20, 2022

Team decision

We will start with zodiacSign(), then we are free to introduce parameters with the specific variant.
The locale will use person.zodiac(sign).western to ensure, future extensibility.

@ST-DDT ST-DDT removed the s: needs decision Needs team/maintainer decision label Oct 20, 2022
@ST-DDT ST-DDT removed the needs rebase There is a merge conflict label Nov 3, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Nov 3, 2022

Done. Ready for Review.

I used faker.definitions.person.western_zodiac_sign as that has better fallback behavior over faker.definitions.person.zodiac_sign.western.

@ST-DDT ST-DDT requested review from Shinigami92, a team and import-brain November 3, 2022 23:09
@Shinigami92 Shinigami92 changed the title feat(person): add westernZodiacSign() feat(person): add zodiacSign() Nov 4, 2022
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.

Could you at least add german locales as well? 🙂

@ST-DDT
Copy link
Member

ST-DDT commented Nov 4, 2022

Could you at least add german locales as well? 🙂

I will do that in a separate PR.

@ST-DDT ST-DDT requested review from pkuczynski and removed request for pkuczynski November 4, 2022 16:47
@ST-DDT ST-DDT enabled auto-merge (squash) November 7, 2022 15:51
@ST-DDT ST-DDT merged commit 7e00d17 into faker-js:next Nov 7, 2022
@luciferreeves luciferreeves deleted the zodiac branch March 15, 2023 23:30
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: person Something is referring to the person module p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add Random Zodiac Signs
6 participants