Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Creates previous_employment_details table#481

Merged
akhilgkrishnan merged 7 commits intodevelopfrom
create-previous-employment-details-table
Jun 16, 2022
Merged

Creates previous_employment_details table#481
akhilgkrishnan merged 7 commits intodevelopfrom
create-previous-employment-details-table

Conversation

@mohinid
Copy link
Contributor

@mohinid mohinid commented Jun 15, 2022

Notion card

https://www.notion.so/saeloun/Add-tables-for-personal-employment-Allocated-devices-compensation-71ef49d0c38e4242bd2998120141372d

Summary

  1. Created previous_employment_details table with fields: company_name and role.
  2. Added associations to EmploymentDetails and CompanyUsers model.
  3. Added. validations on fields.
  4. Added RSpec
  5. Tested manually on Console.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Manually verified associations and validations on the Rails console.

Checklist:

  • I have manually tested all workflows
  • I have performed a self-review of my own code
  • I have added automated tests for my code

Preview of ERD

Employee detail schema ERD

@github-actions
Copy link

github-actions bot commented Jun 15, 2022

Current Code Coverage Percent of this PR:

89.22 %

Files having coverage below 100%

Impacted Files Coverage
/lib/custom_failure.rb 80.0 %
/app/controllers/users/invitations_controller.rb 86.36 %
/app/controllers/users/sessions_controller.rb 85.71 %
/app/services/invoice_payment/checkout.rb 44.0 %
/app/services/invoice_payment/pdf_generation.rb 70.97 %
/app/controllers/internal_api/v1/companies_controller.rb 95.45 %
/app/controllers/internal_api/v1/profile_controller.rb 96.88 %
/app/controllers/internal_api/v1/payment_settings_controller.rb 93.33 %
/app/controllers/internal_api/v1/wise/recipients_controller.rb 90.0 %
/app/controllers/internal_api/v1/payments/providers_controller.rb 94.74 %
/lib/benchmarking/benchmarker.rb 0.0 %

Copy link
Contributor

@rohitjoshixyz rohitjoshixyz left a comment

Choose a reason for hiding this comment

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

Check schema file, rest LGTM

Copy link
Contributor

@apoorv-mishra apoorv-mishra 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 resolve conflicts?

Copy link
Contributor

@apoorv-mishra apoorv-mishra left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Copy link
Member

@akhilgkrishnan akhilgkrishnan left a comment

Choose a reason for hiding this comment

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

@mohinid I've some concerns about this association. The think the previous company details should be directly associated with the User model. For a user, the previous employment should same for each company and it does not vary from company to company.
Eg: Consider, Currently a user belongs to 2 companies A and B. Same user has worked for 3 companies before. As per your flow, the user has 2 employment_details ( for company A and Company B) and each employee details have 3 same previous employees details.
@keshavbiswa @rohitjoshixyz @apoorv-mishra

@rohitjoshixyz
Copy link
Contributor

@akhilgkrishnan Well, it makes sense that we associate the model to users since we are storing only name and role for now. That won't change for any particular individual. It will also reduce a join so let's go for it 👍 @mohinid

@mohinid
Copy link
Contributor Author

mohinid commented Jun 15, 2022

@akhilgkrishnan Well, it makes sense that we associate the model to users since we are storing only name and role for now. That won't change for any particular individual. It will also reduce a join so let's go for it 👍 @mohinid

Thanks, @rohitjoshixyz, @akhilgkrishnan I will change it.

@keshavbiswa
Copy link
Contributor

keshavbiswa commented Jun 15, 2022

, Currently a user belongs to 2 companies A and B. Same user has worked for 3 companies before

Agreed. Shouldn't the same be true for employee_details table?

The user would have the same employee_details regardless of whichever company he is part of.

I mean the user, should have employee_details and previous_employee_details directly or am I missing something?

@mohinid
Copy link
Contributor Author

mohinid commented Jun 15, 2022

, Currently a user belongs to 2 companies A and B. Same user has worked for 3 companies before

Agreed. Shouldn't the same be true for employee_details table?

The user would have the same employee_details regardless of whichever company he is part of.

Hi @keshavbiswa Not really. Please check the fields of employment_details table in ERD. It has employee_id, designation etc which are specific to each company.

@keshavbiswa
Copy link
Contributor

So, if current_user has two company_users records, this would mean the current_user would have two seperate employment_details?

@mohinid
Copy link
Contributor Author

mohinid commented Jun 15, 2022

So, if current_user has two company_users records, this would mean the current_user would have two seperate employment_details?

Yes. because for that user the employment_details varies for both companies.

@mohinid mohinid requested a review from keshavbiswa June 15, 2022 15:10
@rohitjoshixyz
Copy link
Contributor

@keshavbiswa @mohinid I think having a separate table is preferable, because the company_users table is bound to grow as we add more features to Miru instead of having 10 other columns which will be rarely fetched (mostly on the employee profile page)

@mohinid mohinid requested review from keshavbiswa and removed request for keshavbiswa June 15, 2022 15:44
@mohinid
Copy link
Contributor Author

mohinid commented Jun 15, 2022

Updated reference from CompanyUser to User as discussed.
Also, tested on local.
Will update the ERD in next PR!

Copy link
Contributor

@keshavbiswa keshavbiswa left a comment

Choose a reason for hiding this comment

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

Added few suggestions for missing tests, rest LGTM!

Copy link
Member

@akhilgkrishnan akhilgkrishnan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@keshavbiswa keshavbiswa left a comment

Choose a reason for hiding this comment

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

Thanks for making all the changes. Looks good to me!

@mohinid
Copy link
Contributor Author

mohinid commented Jun 15, 2022

Thanks for making all the changes. Looks good to me!

Thanks a lot @keshavbiswa , @akhilgkrishnan & @rohitjoshixyz for your time!! :)
@akhilgkrishnan you can merge now.

Copy link
Contributor

@rohitjoshixyz rohitjoshixyz left a comment

Choose a reason for hiding this comment

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

LGTM

@akhilgkrishnan akhilgkrishnan merged commit 5b53a7b into develop Jun 16, 2022
@akhilgkrishnan akhilgkrishnan deleted the create-previous-employment-details-table branch June 16, 2022 07:22
vipulnsward pushed a commit that referenced this pull request Feb 15, 2026
* Creates previous_employment_details table

* Remove invoice changes from schema.rb

* Update reference from CompanyUser to User

* Additional tests for model

* Addedd dependent-destroy to User-PreviousEmploymentDetails association test

Co-authored-by: Akhil G Krishnan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants