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

Nutrition data and Environment Data parsing #128

Merged
merged 52 commits into from
Feb 27, 2024
Merged

Nutrition data and Environment Data parsing #128

merged 52 commits into from
Feb 27, 2024

Conversation

uglrl
Copy link
Contributor

@uglrl uglrl commented Jan 23, 2024

Pull Request

Added Nutrition Data

Backend

Make sure, you have done de following before merging this pull request:

  • Your code is documented using doc comments.
  • You added appropriate logging in your code.
  • You added unit tests to all your implemented functions.
  • You ran cargo format and cargo clippy to format your code and check for improvements.

@uglrl uglrl requested review from worldofjoni and Whatsuup January 23, 2024 22:34
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

Attention: Patch coverage is 93.67589% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 93.17%. Comparing base (65201a1) to head (e745159).
Report is 43 commits behind head on main.

Files Patch % Lines
...yer/logic/mealplan_management/relation_resolver.rs 53.84% 12 Missing ⚠️
backend/src/layer/trigger/api/types/meal.rs 86.66% 2 Missing ⚠️
backend/src/layer/trigger/api/types/side.rs 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #128      +/-   ##
==========================================
+ Coverage   89.11%   93.17%   +4.06%     
==========================================
  Files          41       38       -3     
  Lines        1653     1671      +18     
==========================================
+ Hits         1473     1557      +84     
+ Misses        180      114      -66     

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

Copy link
Member

@worldofjoni worldofjoni 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 creating the PR.
Looks good to me.

We have to see how we handle these new lints causing errors. Either we disable them or we fix what they tell us (if they are not too much work and don't say anything stupid I think I would prefer the latter)

That is some progress for #124

@worldofjoni worldofjoni changed the title Nutrition data Nutrition data parsing Jan 24, 2024
@worldofjoni
Copy link
Member

One further question: @uglrl did you include that in the test cases? It looks like but I want to make sure.

@Whatsuup
Copy link
Contributor

Looks good to me as well.

I would suggest parsing more than just the nutrition stats, as we're here:

  • CO2 emission score
  • Water consumption score
  • Animal welfare score
  • Rainforest suffer score

Tell me how you think about that idea.

https://www.sw-ka.de/de/hochschulgastronomie/qualitaet_nachhaltigkeit/nachhaltigkeit/

Copy link
Member

@worldofjoni worldofjoni left a comment

Choose a reason for hiding this comment

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

Cool that you continued working hereon!
There are some problems, however...
I think it is not worth it to change all those names with an external dependency now (database, API) as it is too much of a hassle and too dangerous (that can break things).

backend/migrations/20230703130438_food.up.sql Outdated Show resolved Hide resolved
backend/src/layer/data/swka_parser/test_data/test_1.html Outdated Show resolved Hide resolved
backend/src/layer/trigger/api/types/meal.rs Outdated Show resolved Hide resolved
@uglrl uglrl changed the title Nutrition data parsing Nutrition data and Environment Data parsing Feb 14, 2024
@worldofjoni
Copy link
Member

worldofjoni commented Feb 18, 2024

Changes to the Graphql schema:
@AlexKutschera you may want to take a look at that and approve

type Meal {
  # The identifier of the main course.
  id: UUID!

  # The name of the main course.
  name: String!
  
  # ...

  # Provides the environment information of this meal.
  environmentInfo: EnvironmentInfo

  # Provides the nutrition data of this meal.
  nutritionData: NutritionData
}


type Side {
  # The id of the side
  id: UUID!

  # The name of the side
  name: String!

  # ...

  # Provides the environment information of this meal.
  environmentInfo: EnvironmentInfo

  # Provides the nutrition data of this meal.
  nutritionData: NutritionData
}


# This struct contains all environmental information. co2 in grams, water in litres
type EnvironmentInfo {
  # The average environmental rating. Out of `max_rating`
  averageRating: Int!

  # The number of stars the food has for CO2 emmissions. Out of `max_rating`
  co2Rating: Int!

  # The amount of CO2 emitted by the production of the food. In grams
  co2Value: Int!

  # The number of stars the food has for water consumption. Out of `max_rating`
  waterRating: Int!

  # The amount of water used for the production of the food. In Millilitres
  waterValue: Int!

  # The number of stars the food has for animal welfare. Out of `max_rating`
  animalWelfareRating: Int!

  # The number of stars the food has for rainforest preservation. Out of `max_rating`
  rainforestRating: Int!

  # The maximum amount of stars for each category
  maxRating: Int!
}

# The nutrients of a dish
type NutritionData {
  # Energy in Kcal
  energy: Int!

  # Protein in grams
  protein: Int!

  # Carbs in grams
  carbohydrates: Int!

  # Sugar in grams
  sugar: Int!

  # Fat in grams
  fat: Int!

  # Saturated fat in grams
  saturatedFat: Int!

  # Salt in grams
  salt: Int!
}

schema.graphq.txt

@worldofjoni worldofjoni mentioned this pull request Feb 21, 2024
backend/migrations/20240214192738_food_env_score.up.sql Outdated Show resolved Hide resolved
backend/src/layer/data/database/request.rs Show resolved Hide resolved
backend/src/layer/trigger/api/query.rs Outdated Show resolved Hide resolved
backend/src/util.rs Show resolved Hide resolved
@worldofjoni
Copy link
Member

Besides these notes, I think we are ready to merge.

@worldofjoni
Copy link
Member

FYI: I have also ignored the startup files regarding test coverage, so we are now well above 90% again

@worldofjoni worldofjoni changed the base branch from backend to main February 27, 2024 21:40
@uglrl uglrl linked an issue Feb 27, 2024 that may be closed by this pull request
@uglrl uglrl merged commit 7ded4f6 into main Feb 27, 2024
10 checks passed
@uglrl uglrl deleted the nutrition_data branch February 27, 2024 22:01
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.

Nutrition stats
4 participants