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

Feature/salary calculator #156

Merged

Conversation

ShiZinDle
Copy link
Contributor

New feature - Salary Calculator:
allows users to select any category they previously created and create salary calculation settings for it. the feature also adds edit pages for the settings and view pages for the calculations. The calculation will be done for the chosen month and will be based on all events that are labeled with the corresponding category. Multiple salary settings are allowed, but only 1 for each user and category combination.

Further changes implemented:
-moved contents of file "app.database.database" to "app.database" for easier access.
-moved function "app.database,database.get_db" to "app.dependencies.get_db".
-merged file "tests.utils" into "app.internal.utils" to prevent code duplication.
-fixed imports and type hints where necessary.

@ShiZinDle ShiZinDle changed the base branch from main to develop January 30, 2021 19:43
@PureDreamer
Copy link
Contributor

In order to pass the tests you need the files to be ok with flake8, you can choose flake8 as a linter, and it will show you where are your mistakes.

@ShiZinDle ShiZinDle closed this Jan 31, 2021
@ShiZinDle ShiZinDle reopened this Jan 31, 2021
@ShiZinDle
Copy link
Contributor Author

All linting errors, code conflicts and failing tests have been fixed and resolved.

Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Wow! That's some effort you put in this PR. Awesome job!

.gitignore Outdated Show resolved Hide resolved
app/database/database.py Show resolved Hide resolved
app/database/models.py Show resolved Hide resolved
from typing import Union


MINIMUM_WAGE = 29.12
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 please move this to setting-per-user basis?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand your intention. Theses are the default values displayed to the user for settings creation (and also default values for the db model) but are editable by the user and saved on the db.


@router.post('/view/{category_id}')
@router.get('/view/{category_id}')
async def view_salary(request: Request, category_id: int) -> Response:
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 please split this function into multiple functions?


@router.post('/edit')
@router.get('/edit')
async def pick_settings(request: Request) -> Response:
Copy link
Member

Choose a reason for hiding this comment

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

Split to two functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have attempted to split all path operations into separate function, but after doing so the app failed to work properly and redirections caused disconnections rather than the wanted results. I have saved the new file and will look into it some more. Please let me know if you know why this might happen. (I haven't made any changes to the logic of the code besides splitting it to separate functions.)

app/routers/salary/utils.py Show resolved Hide resolved
app/routers/salary/utils.py Outdated Show resolved Hide resolved
app/routers/salary/utils.py Outdated Show resolved Hide resolved
app/routers/salary/utils.py Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Feb 1, 2021

Codecov Report

Merging #156 (4d2c7f9) into develop (4df85bc) will increase coverage by 0.07%.
The diff coverage is 99.77%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #156      +/-   ##
===========================================
+ Coverage    99.29%   99.36%   +0.07%     
===========================================
  Files           41       44       +3     
  Lines         1691     2059     +368     
===========================================
+ Hits          1679     2046     +367     
- Misses          12       13       +1     
Impacted Files Coverage Δ
app/routers/event_images.py 100.00% <ø> (ø)
app/database/models.py 96.55% <97.61%> (-0.06%) ⬇️
app/database/__init__.py 100.00% <100.00%> (ø)
app/dependencies.py 100.00% <100.00%> (ø)
app/internal/event.py 100.00% <100.00%> (ø)
app/internal/import_file.py 100.00% <100.00%> (ø)
app/internal/json_data_loader.py 100.00% <100.00%> (ø)
app/internal/on_this_day_events.py 90.62% <100.00%> (ø)
app/internal/search.py 100.00% <100.00%> (ø)
app/internal/translation.py 100.00% <100.00%> (ø)
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7df0615...4d2c7f9. Read the comment docs.

Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Awesome job, added few additional insights

app/database/models.py Show resolved Hide resolved
app/internal/search.py Show resolved Hide resolved
tests/salary/conftest.py Outdated Show resolved Hide resolved
app/routers/salary/utils.py Outdated Show resolved Hide resolved
app/internal/search.py Show resolved Hide resolved
Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Awesome, a little fix and it's ready to merge from my side. Please also solve the conflicts :)

settings = session.query(SalarySettings).filter(and_(
SalarySettings.user_id == user_id, SalarySettings.category_id
== category_id)).first()
session.close()
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't really say why, but for some reason removing this line fails one of my tests.
The functionality is essentially the same, and the service itself doesn't seem to be affected, yet I didn't manage to pass the tests without it.
If you want to take a look at it, the one that fails is "test_routes: :test_edit_settings".

Copy link
Member

@yammesicka yammesicka Feb 7, 2021

Choose a reason for hiding this comment

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

Try to git checkout upstream/develop -- requirements.txt and pip install -U -r requirements.txt.
We've downgraded the pytest-asyncio library, that's might solve the problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this did not solve the problem.

@yammesicka
Copy link
Member

While trying to solve conflicts, I've seen there is a minor problem with test_events.py. Can you please take a look? :)

@ShiZinDle
Copy link
Contributor Author

While trying to solve conflicts, I've seen there is a minor problem with test_events.py. Can you please take a look? :)

There was a missing import, now fixed.

@yammesicka yammesicka merged commit 2f99b05 into PythonFreeCourse:develop Feb 10, 2021
@ShiZinDle ShiZinDle deleted the feature/salary-calculator branch February 10, 2021 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants