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

add child questions backend code #146

Merged
merged 17 commits into from
Nov 7, 2024
Merged

add child questions backend code #146

merged 17 commits into from
Nov 7, 2024

Conversation

MaHaWo
Copy link
Collaborator

@MaHaWo MaHaWo commented Nov 6, 2024

  • add ChildQuestion and ChildAnswer database models
  • add default child questions which are added when the database is initialized
    • name
    • birth date
    • remarks
    • optional file upload for image
      These are intended to fill the Child model upon registration of a new child. They have fixed question-ids of 1 to 4 in the ChildQuestion table in the above order.
  • add tests for new code
  • unify model classes via inheritance for questions, answers where easily possible, i.e., where no sql tables are involved.
  • sonarcloud complaint is about about duplication in autogenerated code. Not sure if this should be adressed.

a substantial chunk of the changed LoC is autogenerated openapi code, so this PR isn´t quite as big as it seems.

@MaHaWo MaHaWo changed the title add child questions backend code from pr 138 add child questions backend code Nov 6, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.07%. Comparing base (06f1284) to head (c90409d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #146      +/-   ##
==========================================
+ Coverage   26.83%   29.07%   +2.24%     
==========================================
  Files          93       93              
  Lines        3455     3529      +74     
  Branches      122      122              
==========================================
+ Hits          927     1026      +99     
+ Misses       2461     2436      -25     
  Partials       67       67              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MaHaWo MaHaWo requested a review from lkeegan November 6, 2024 15:18
Copy link
Member

@lkeegan lkeegan left a comment

Choose a reason for hiding this comment

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

lgtm! some minor comments

},
)
)
session.add(
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 adding default questions to the database is a good idea - not sure about including the date of birth though as:

  • it's already part of the child model (since we need it to determine which milestones a child gets)
  • also I think it was only year/month in the initial requirements (opened an issue for this full date of birth for children? #147)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the problem is here that the data of the child gets sourced through the same interface, i.e., ChildDataInput.svelte. For the user, we don´t have this because the user needs credentials upon registration and the questions then are a whole separate thing. So, unless we want to do something similar for the child (which from a user perspective would be a bit weird imho, but tolerable), we have to put entries for name and birth month/year/whatever into the questions table, and they need to be default questions because any new child MUST have them. The full date comes in b/c I think it's a more usable component in the frontend to have the usual calender selection widget rather than having to type out month and year.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, so after our discussion, I removed the default questions. I believe that we would need some input to know what would be reasonable defaults, and the 'remark' question that was left after removing the ones that populate Child objects didn't seem useful enough to put in as a fixed thing.

mondey_backend/src/mondey_backend/models/questions.py Outdated Show resolved Hide resolved
mondey_backend/src/mondey_backend/routers/users.py Outdated Show resolved Hide resolved
mondey_backend/src/mondey_backend/routers/users.py Outdated Show resolved Hide resolved
mondey_backend/src/mondey_backend/routers/users.py Outdated Show resolved Hide resolved
mondey_backend/src/mondey_backend/routers/users.py Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Nov 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
7.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@MaHaWo
Copy link
Collaborator Author

MaHaWo commented Nov 7, 2024

@lkeegan you want to have another look?

Copy link
Member

@lkeegan lkeegan left a comment

Choose a reason for hiding this comment

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

lgtm!

@MaHaWo MaHaWo merged commit e1767e6 into main Nov 7, 2024
5 of 6 checks passed
@MaHaWo MaHaWo deleted the add-childrenquestion-backend branch November 7, 2024 14:09
Majapur1 pushed a commit that referenced this pull request Nov 14, 2024
merge #146 (add-childquestion-backend) into main
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.

3 participants