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

Improvement: refactor expected_fields_validator #243

Open
4 tasks
codesankalp opened this issue Mar 29, 2021 · 10 comments
Open
4 tasks

Improvement: refactor expected_fields_validator #243

codesankalp opened this issue Mar 29, 2021 · 10 comments
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. hacktoberfest Open Source Hack Status: Available Issue was approved and available to claim or abandoned for over 3 days.
Projects

Comments

@codesankalp
Copy link
Member

Description

As a developer,
I need validators to be fast,
so that API response time will be less.

Mocks

expected_fields = []
for field_input in user_input:
for field_expected in data_model:
if field_input == field_expected:
expected_fields.append(field_input)
if len(expected_fields) != len(data_model):
return {"is_field_valid": False, "message": messages.UNEXPECTED_INPUT}
return {"is_field_valid": True, "message": {}}

The two for loops can be implemented efficiently by using the python built-in function.
I think there is no need for two for loops for this.

Acceptance Criteria

Update [Required]

  • Remove two for loops.
  • Use python builtin function to return the actual validation (described in docstrings of function).

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

0.5 hours

@codesankalp codesankalp added Category: Coding Changes to code base or refactored code that doesn't fix a bug. First Timers Only Good for newcomers. Open Source Hack Status: Available Issue was approved and available to claim or abandoned for over 3 days. labels Mar 29, 2021
@KushalBeniwal
Copy link

@codesankalp I would like to work on this issue.

@decon-harsh
Copy link
Member

decon-harsh commented Apr 2, 2021

@KushalBeniwal Have you completed the mandatory setup task #244 before claiming a coding/testing issue?

@KushalBeniwal
Copy link

@decon-harsh, no, I haven't. I will do that first.

@devkapilbansal
Copy link
Member

@KushalBeniwal comment once you do the setup task

@KushalBeniwal
Copy link

I am unable to follow from this step https://github.com/anitab-org/bridge-in-tech-backend/blob/develop/.github/ENV_SETUP_INSTRUCTION.md#4th-open-pgadmin4, as I am using wsl, so, I can only use the command line.

@decon-harsh
Copy link
Member

decon-harsh commented Apr 2, 2021

I am unable to follow from this step https://github.com/anitab-org/bridge-in-tech-backend/blob/develop/.github/ENV_SETUP_INSTRUCTION.md#4th-open-pgadmin4, as I am using wsl, so, I can only use the command line.

Please join our zulip chat and ask your doubts there, we will be happy to help you with your Dev env setup. @KushalBeniwal

@mtreacy002 mtreacy002 added this to Icebox in BIT Roadmap Apr 4, 2021
@y-martinez
Copy link
Contributor

I would like to work on this issue if is available, but I have a question. user_input and data_model are always int arrays, right?

@epicadk epicadk removed the Status: Available Issue was approved and available to claim or abandoned for over 3 days. label Apr 11, 2021
@y-martinez
Copy link
Contributor

y-martinez commented Apr 12, 2021

Hi @epicadk or @mtreacy002 a maybe possible solution could be to use the data structure set to compare if user_input and data_model are exact the same, however, I saw that in tests are falling, but the problem apparently is the code, so, I have a question, I need to verify that always user input fields contain only the expected fields of the data model? not more and not less right?, I have that doubt because so I think that I found an error in the code but I am not sure

@mtreacy002
Copy link
Member

@y-martinez , can you please explain what you mean with

I need to verify that always user input fields contain only the expected fields of the data model? not more and not less right?, I have that doubt because so I think that I found an error in the code but I am not sure

@vj-codes
Copy link
Member

@y-martinez any updates?

@isabelcosta isabelcosta added hacktoberfest Status: Available Issue was approved and available to claim or abandoned for over 3 days. and removed First Timers Only Good for newcomers. labels Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. hacktoberfest Open Source Hack Status: Available Issue was approved and available to claim or abandoned for over 3 days.
Projects
BIT Roadmap
New Issues
Development

No branches or pull requests

9 participants