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: Add BIT personal background to MS schema #1092

Open
wants to merge 10 commits into
base: bit
Choose a base branch
from

Conversation

mtreacy002
Copy link
Member

Description

Added BIT Personal Background to MS schema

Fixes #1091

Type of Change:

  • Code

Code/Quality Assurance Only

  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

  • run existing tests and confirmed all tests passed.

Screen Shot 2021-05-03 at 10 58 58 am

  • run migration script (to create new alembic version for updated schema) successfully.

Screen Shot 2021-05-03 at 11 43 14 am

Screen Shot 2021-05-03 at 11 41 16 am

Screen Shot 2021-05-03 at 11 44 21 am

Screen Shot 2021-05-03 at 11 42 15 am

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials
  • I have commented my code or provided relevant documentation, particularly in hard-to-understand areas

Code/Quality Assurance Only

  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

@mtreacy002 mtreacy002 marked this pull request as draft May 3, 2021 01:48
@mtreacy002 mtreacy002 added BIT This labels issues that need to be completed to help BIT Category: Coding Changes to code base or refactored code that doesn't fix a bug. Type: Enhancement New feature or request. labels May 3, 2021
Add new migration script

reformat to black linting
@codecov
Copy link

codecov bot commented May 3, 2021

Codecov Report

Merging #1092 (f8c0c12) into bit (f25a0b8) will decrease coverage by 0.26%.
The diff coverage is 90.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##              bit    #1092      +/-   ##
==========================================
- Coverage   94.50%   94.24%   -0.27%     
==========================================
  Files          39       40       +1     
  Lines        2677     2868     +191     
==========================================
+ Hits         2530     2703     +173     
- Misses        147      165      +18     
Impacted Files Coverage Δ
app/database/models/personal_background.py 90.19% <90.19%> (ø)
app/utils/bitschema_utils.py 98.20% <90.55%> (-1.64%) ⬇️
run.py 94.87% <92.85%> (-1.29%) ⬇️

@mtreacy002 mtreacy002 marked this pull request as ready for review May 3, 2021 01:59
@mtreacy002 mtreacy002 requested review from isabelcosta and epicadk May 3, 2021 01:59
@mtreacy002
Copy link
Member Author

@isabelcosta and @epicadk .The codecov %-tages are dropping since I didn't add a test_database_models for personal background. Do you want me to add the test on this PR or add later in a separate one?

@@ -0,0 +1,146 @@
from sqlalchemy import null
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment here specifying that this is a BIT extension?

db.create_all()

@application.shell_context_processor
def make_shell_context():
return {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this required?

Copy link
Member Author

Choose a reason for hiding this comment

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

@epicadk , tbh this is my first attempt doing migration. I'm using the shell_context_processor based from what I gathered here. Please do let me know how to improve this 😉 .

@unique
class SexualOrientation(Enum):
HETEROSEXUAL = "Heterosexual/Straight"
LGBTIA = "LGBTIA+"
Copy link
Member

Choose a reason for hiding this comment

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

I think you forgot the Q LGBTQIA ?

Copy link
Member Author

Choose a reason for hiding this comment

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

will make the change soon 😉

years_of_experience = db.Column(db.Enum(YearsOfExperience))
others = db.Column(JsonCustomType)
is_public = db.Column(db.Boolean)

Copy link
Member

Choose a reason for hiding this comment

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

Not sure why exactly we would need such information. I'll leave that to @isabelcosta

Copy link
Member Author

Choose a reason for hiding this comment

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

@epicadk , do you mean years of experience? First of all, I believe this is relevant to support one of BIT goals which is to improve equity in IT because many with no to limited years of experience in IT were left out from employment opportunity. We often see a position for entry level required more than 3 - 5 years of experience. Stating this years of experience encouraging industries to target people within the lower years of experience to be the mentee and people with the higher level of experience to be the mentor. Their willingness to go against the norm in employment market (aka to be more inclusive by targeting those within the minority groups, e.g. minimal years of experience) is going to be highlighted in the BIT Landing page as per the Mockup in my GSoC20 proposal.
image


@unique
class YearsOfExperience(Enum):
UNDER_ONE = "Less than a year"
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to just store numbers (number of years of experience) in the database instead of storing strings.

Copy link
Member Author

@mtreacy002 mtreacy002 May 5, 2021

Choose a reason for hiding this comment

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

@epicadk , the reason I did it like this (in word instead of number) is because IMO it makes more sense when an organization open a mentoring program opportunity, they can state the target candidate based on a range of years of experience (e.g. between 3 to 5 years) instead of a distinct year 1,2,3, or 4 yr etc. This is also to make it easier for later when we make the logic which allows user to filter mentoring program based on certain categories (e.g. years of experience required "between 3 - 5 years" instead of selecting a particular number like 1,2,3 or 4 yr etc). This way it also limits the options to 5 only. Hope this makes sense 😉 .
image

Copy link
Member

Choose a reason for hiding this comment

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

We can still make the same query with databases ( possibly more optimized as well if we use indexing) further every year we could just ++ the count in the database rather than having to migrate the strings.

Copy link
Member Author

Choose a reason for hiding this comment

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

@epicadk , what do you mean by

further every year we could just ++ the count in the database rather than having to migrate the strings.

Do you mean we need to make a scheduler to automatically add one year to the years of experience of each users who have this data instead of users manually updating their years of experience from their end? We could do that I suppose, but we're at disadvantage when the user is no longer in the industry but hasn't cancelled their membership/delete their account with us as that would be an inefficient use of overhead, plus we don't know how many of our users are in this category 🤔 .

Let's wait for @isabelcosta's opinion on this 😉 .

Copy link
Member

@devkapilbansal devkapilbansal left a comment

Choose a reason for hiding this comment

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

@mtreacy002 code coverage is descreasing significantly. I think new test cases are also needed with changes.

@mtreacy002
Copy link
Member Author

@mtreacy002 code coverage is descreasing significantly. I think new test cases are also needed with changes.

Ok, will add the test for the database model then 👍

@mtreacy002
Copy link
Member Author

Hi @devkapilbansal & @epicadk , does any you have a suggestion on how to increase the test coverage? I really appreciate any input 😉

@epicadk
Copy link
Member

epicadk commented May 6, 2021

Hi @devkapilbansal & @epicadk , does any you have a suggestion on how to increase the test coverage? I really appreciate any input 😉

90 to 95% Coverage is fine as long as the tests cover all possible cases.

user_id: An integer for storing the user's id.
gender: A string for storing the user's gender.
age: A string for storing the user's age.
ethnicity: A string for storing the user's wthnicity.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ethnicity: A string for storing the user's wthnicity.
ethnicity: A string for storing the user's ethnicity.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @mtreacy002 this is not resolved yet

background = PersonalBackgroundModel.query.filter_by(
user_id=self.user2.id
).first()
self.assertTrue(background is not None)
Copy link
Member

Choose a reason for hiding this comment

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

just as a fyi, you can do also assertIsNotNone() I think it's like this 🤔
not that you need to change, just wanted to let you know ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot about that 🤣 . Thanks @isabelcosta for the reminder. I've fixed it now 😉 .

@mtreacy002 mtreacy002 requested a review from isabelcosta May 8, 2021 22:09

# default values
self.others = None
self.is_public = False
Copy link
Member

Choose a reason for hiding this comment

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

I think this should not be a boolean option.
I would say this could be an enum to represent different visibility levels. E.g.:

  • Not visible to anyone
  • Visible to BIT only
  • Visible to Organizations only
  • Visible to all users (probably no one will select this though 🤔 )

Copy link
Member

@isabelcosta isabelcosta left a comment

Choose a reason for hiding this comment

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

I will approve this, as this is AS IS from BIT backend code, but lets try to after this merge, address the 2 review comments we discussed in the Open Session:

  • removing religious questions
  • making personal background visibility an enum instead of a boolean

@isabelcosta isabelcosta added the Status: Needs Testing Work has been reviewed and needs the code tested by the quality assurance team. label May 16, 2021
@mtreacy002
Copy link
Member Author

I will approve this, as this is AS IS from BIT backend code, but lets try to after this merge, address the 2 review comments we discussed in the Open Session:

  • removing religious questions
  • making personal background visibility an enum instead of a boolean

Noted. Thank you @isabelcosta . Will open the issues and work on these points once this pr is approved 😉

@mtreacy002
Copy link
Member Author

@isabelcosta , @vj-codes and @epicadk , can you please advise if there's anything else need to be done here? Thanks 😉

@isabelcosta
Copy link
Member

@mtreacy002 have you tested this and are you confident this is working ok? Since we are merging to BIT branch, I trust you on this. Happy to merge, just give me the green light 🤗

@mtreacy002
Copy link
Member Author

@mtreacy002 have you tested this and are you confident this is working ok? Since we are merging to BIT branch, I trust you on this. Happy to merge, just give me the green light 🤗

@isabelcosta , I'm pretty sure I've tested it locally though I haven't written the test report since I was hoping others could help with the testing part. But, I'll do it asap and will write the test summary soon 😉.

@vj-codes
Copy link
Member

@mtreacy002 I can also test this, all I need to do is pull it locally and run unittests right?

@mtreacy002
Copy link
Member Author

@mtreacy002 I can also test this, all I need to do is pull it locally and run unittests right?

That's right, @vj-codes . Thank you, that'll be great, please 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BIT This labels issues that need to be completed to help BIT Category: Coding Changes to code base or refactored code that doesn't fix a bug. Status: Needs Testing Work has been reviewed and needs the code tested by the quality assurance team. Type: Enhancement New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants