Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test

on:
push:
branches: [ v2 ]
pull_request:
branches: [ v2 ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
# This workflow contains a single job called "build"
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.11.3]
steps:
- uses: actions/checkout@v4

- name: Check typos in code
run: |
echo "Checking typos in code"
pip3 install typos
typos
8 changes: 8 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[default]
extend-ignore-identifiers-re = [
"Longe",
"servie",
"admn",
"Brocoli",
"sur"
]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ For Ubuntu, see [Setting up the backend (postgraphile) on Ubuntu](../../wiki/Set

The mealplanner project can be built and run using docker-compose on platforms that support Docker (Linux, MacOS, Windows 10)

In the main project directory there is a docker-compose.yml file that will build and run three containers: postgres, graphl backend and the frontend application. The postgres container uses a standard psotgres image from docker hub, the other two will be built on top of the node:12 container. The Dockerfiles in the backend and meal-planner-fredericton-ui directories decribe the builds.
In the main project directory there is a docker-compose.yml file that will build and run three containers: postgres, graphl backend and the frontend application. The postgres container uses a standard psotgres image from docker hub, the other two will be built on top of the node:12 container. The Dockerfiles in the backend and meal-planner-fredericton-ui directories describe the builds.

### Pre-requisites

Before composing the application you must ensure that Docker is installed and functioning. A quick check is to run `docker version` on the command line to see if you get any output. If you get an error, see the Docker set up for your platfrom.
Before composing the application you must ensure that Docker is installed and functioning. A quick check is to run `docker version` on the command line to see if you get any output. If you get an error, see the Docker set up for your platform.

- Ubuntu - this should be as simple as `sudo apt install docker docker-compose docker.io python3-docker python3-dockerpty` . To enable Docker access for the current user, run the following command in the terminal: `sudo usermod -a -G docker $USER`. It's important to note that after running the command, you need to log out and log back in for the changes to take effect.
- MacOS [Docker Desktop for Mac](https://docs.docker.com/docker-for-mac/install/)
- Windows 10 [Docker Desktop for Windows 10](https://docs.docker.com/docker-for-windows/install/)

It is recomended to perform the install and "getting started" steps for Docker Desktop before proceeding.
It is recommended to perform the install and "getting started" steps for Docker Desktop before proceeding.

## Important Notice

Expand All @@ -39,7 +39,7 @@ If you are running a Linux distribution, Docker can be installed directly from t
Please refer to the official documentation or community resources specific to your Linux distribution for guidance on installing and managing Docker and KVM.


Now that Docker is available, set up the environment for the composed applications. In the main project folder, where the `docker-compose.yml` file is, create a file named `.env` and add two variables to it. These are a databse password and a token secret. Both should be treated like passwords and should be reasonably unique and random. This is and example (please don't use these passwords, create your own):
Now that Docker is available, set up the environment for the composed applications. In the main project folder, where the `docker-compose.yml` file is, create a file named `.env` and add two variables to it. These are a database password and a token secret. Both should be treated like passwords and should be reasonably unique and random. This is and example (please don't use these passwords, create your own):

```
POSTGRES_PASSWORD=databasepassword
Expand All @@ -66,7 +66,7 @@ docker-compose up --build
```

### populating sample data
On the initial build and startup, the database will be completely empty. There won't even be an account created for logging in. To populate the databse with a handful of users and some recipe material run the appropriate version of the following docker-compose commands to seed the database.
On the initial build and startup, the database will be completely empty. There won't even be an account created for logging in. To populate the database with a handful of users and some recipe material run the appropriate version of the following docker-compose commands to seed the database.

On Linux or MacOS:

Expand All @@ -83,7 +83,7 @@ Get-Content .\backend\seed.sql | docker-compose exec -T db /usr/bin/psql -U post
```


Pay careful attention to the output as it will include the randomly generated passwords for the defaul users. This will look something like the following but the passwords will be unique each time:
Pay careful attention to the output as it will include the randomly generated passwords for the default users. This will look something like the following but the passwords will be unique each time:

```
BEGIN
Expand Down
6 changes: 3 additions & 3 deletions admin-ui/src/Nutrition/NutritionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export const NutritionForm = () => {
<NumberInput source="transFat" />
<TextInput source="transFatUnit" />
<NumberInput source="transFatPercent" />
<NumberInput source="cholestrol" />
<TextInput source="cholestrolUnit" />
<NumberInput source="cholestrolPercent" />
<NumberInput source="cholesterol" />
<TextInput source="cholesterolUnit" />
<NumberInput source="cholesterolPercent" />
<NumberInput source="sodium" />
<TextInput source="sodiumUnit" />
<NumberInput source="sodiumPercent" />
Expand Down
6 changes: 3 additions & 3 deletions admin-ui/src/Nutrition/NutritionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ const Details = () => {
<NumberField source="transFat" />
<TextField source="transFatUnit" />
<NumberField source="transFatPercent" />
<NumberField source="cholestrol" />
<TextField source="cholestrolUnit" />
<NumberField source="cholestrolPercent" />
<NumberField source="cholesterol" />
<TextField source="cholesterolUnit" />
<NumberField source="cholesterolPercent" />
<NumberField source="sodium" />
<TextField source="sodiumUnit" />
<NumberField source="sodiumPercent" />
Expand Down
6 changes: 3 additions & 3 deletions admin-ui/src/Nutrition/NutritionShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const NutritionShow = () => {
<NumberField source="transFat" />
<TextField source="transFatUnit" />
<NumberField source="transFatPercent" />
<NumberField source="cholestrol" />
<TextField source="cholestrolUnit" />
<NumberField source="cholestrolPercent" />
<NumberField source="cholesterol" />
<TextField source="cholesterolUnit" />
<NumberField source="cholesterolPercent" />
<NumberField source="sodium" />
<TextField source="sodiumUnit" />
<NumberField source="sodiumPercent" />
Expand Down
2 changes: 1 addition & 1 deletion backend/004-meal.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ comment on column app.meal.name_fr is 'Short name or title in French';
comment on column app.meal.tags is 'A list of tags (strings) used to apply attributes to the Meal/recipe. May include things like "vegetarian" or "contains peanuts" to facilitate filtering and matching with user''s dietrary needs and so forth. Tag values are determined by the user.';
comment on column app.meal.description_en is 'Longer form description of the recipe to complement the name, in English';
comment on column app.meal.description_fr is 'Longer form description of the recipe to complement the name, in French';
comment on column app.meal.categories is 'Categories for which this Meal is appropriate. This is used to restrict Categories to which a Meal may be assigned within a Meal Plan. These iclude "Breakfast", "Lunch", "Dinner", "Snack"';
comment on column app.meal.categories is 'Categories for which this Meal is appropriate. This is used to restrict Categories to which a Meal may be assigned within a Meal Plan. These include "Breakfast", "Lunch", "Dinner", "Snack"';
comment on column app.meal.photo_url is '??';
comment on column app.meal.video_url is '??';
comment on column app.meal.method is 'The instructions for preparing the recipe, usually in point form. Plain text formatting determined by the user.';
Expand Down
2 changes: 1 addition & 1 deletion backend/example_query_annotated.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with meals_arr as (
)
) as "@nodes"
from "app"."meal_products"(meals_rel) as products_rel -- this is a function call
where (TRUE) and (TRUE) -- totally superflous
where (TRUE) and (TRUE) -- totally superfluous
),
products_arr_data as (
select json_agg(
Expand Down
2 changes: 1 addition & 1 deletion backend/migrations/001-241-meal-plan-entry-policy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ create policy all_meal_plan_entry_meal_designer
for all
to app_meal_designer using(true);

-- user can only see or update entries beloning to their own meal plans
-- user can only see or update entries belonging to their own meal plans
-- IMPORTANT: the row level policy on meal_plan must be in place for this to work
drop policy if exists all_meal_plan_entry_user on app.meal_plan_entry;
create policy all_meal_plan_entry_user
Expand Down
8 changes: 4 additions & 4 deletions mealplanner-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ In Version 2 of meal planner,we are using TypeScript and updated version of Rela
Upgrading Relay as we are going to use hooks such as PreLoadedQuery as the version 9.1.0 used in the current code doesn’t support.

1. DashBoard
1. Dashboard component will be simplifed by extracting them as different components
1. Dashboard component will be simplified by extracting them as different components
1. QueryRenderer and Refetch container becomes PreloadedQuery in Dashboard component.
2. The people filter menu will be its own component with its associated fragment.
3. DeleteDialog - use `@deleteEdge` on the commit mutation to automatically drop the edge and avoid a refetch.
2. Extract selected person into its own local state. (Implementing state using Relay - commitLocalUpdate and seperate graphQL file for state extending the Query type.)
2. Extract selected person into its own local state. (Implementing state using Relay - commitLocalUpdate and separate graphQL file for state extending the Query type.)
3. If and when pagination is implemented this client side filter will break i.e. if the record is not present for that user in the first page, but in the subsequent pages, it will show as no records found. So we need to use the condition in graphQL and refetch when the peoplefilter changes.
2. Mealplan page
1. Create Plan option: a better name would be meal selector.
Expand All @@ -77,10 +77,10 @@ Upgrading Relay as we are going to use hooks such as PreLoadedQuery as the versi
4. MealplansToolbar - It unnecessarily queries all the fields on the meal plan while it displays only the meal plan name and the user name. So query needs to be modified to include only the meal plan name and username.
5. CreatePlanTable - should contain the meal plan entry details for the current meal plan. As of now that part of the query fragment is in MealplansToolbar.
6. Create a type for global state to include isCreateMPModalOpen, isDuplicateMPModalOpen, createMPConfig, duplicateMPConfig instead of using local state such as newModalOpen and selectedPlan controlled by the toolbar so that eventually we avoid prop drilling. Remove unnecessary states such as alreadySelectedMealAfterNav.
7. New, Duplicate, Save is as 3 different buttons in the current release. This can all be combined to one. There can be just one modal which gives the option for the new meal plan which offers existing meal plan as template option and the other as from scratch. We can save as an when the meal is getting dropped instead of having a seperate save button.
7. New, Duplicate, Save is as 3 different buttons in the current release. This can all be combined to one. There can be just one modal which gives the option for the new meal plan which offers existing meal plan as template option and the other as from scratch. We can save as an when the meal is getting dropped instead of having a separate save button.
8. MealplansToolbar - We will use the mealplan ID in the url and avoid using useLocation and useEffect. Instead we can use useParams.
9. MealPlanAssignment - This assigns users. mutation will move from PlanPage to MealPlanAssignment and eliminating the need of a save button or props drilling. This will also read from the global state.
10. Duplicate meal plan is going part of new meal plan itself as an option to select mealplan from a template rather than a seperate button.
10. Duplicate meal plan is going part of new meal plan itself as an option to select mealplan from a template rather than a separate button.
11. The mutation of NewMealPlanModal is containing mealplan entries which is not available in a new mealplan. We need not query for it. NewMealPlanModal is in MealplanToolbar, but it should be in PlanPage.
12. In Delete functionality as of now I am doing relay.refetch(). This can be avoided with `@deleteEdge` with connections.
13. createMealPlanEntry is creating an array of promises and making so many network calls in a single SAVE button click. However we can push those entries to the database as and when it is created. This would eliminate requirement for mealEntryAlreadyExists, mealEntryHasBeenRemoved.
Expand Down
4 changes: 2 additions & 2 deletions mealplanner-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ const theme = createTheme({
initState();

function App() {
let [intialized, setInitialized] = useState(false);
let [initialized, setInitialized] = useState(false);
useEffect(() => {
fetchCurrentPerson().then(() => {
setInitialized(true);
});
}, []);
if (!intialized) {
if (!initialized) {
return <h1>loading...</h1>;
}

Expand Down
2 changes: 1 addition & 1 deletion mealplanner-ui/src/pages/MealPlans/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DesktopCalendar } from "./DesktopCalendar";
import { MobileCalendar } from "./MobileCalendar";
import { Calendar_mealPlan$key } from "./__generated__/Calendar_mealPlan.graphql";

// Refered https://relay.dev/docs/guided-tour/list-data/updating-connections/ documentation for @connection, __id
// Referred https://relay.dev/docs/guided-tour/list-data/updating-connections/ documentation for @connection, __id
// The example does not work exactly. It threw errors that first or last should be included
// The second error was edges was missing
// Complained Calendar_mealPlan_mealPlanEntries_connection should be Calendar_mealPlan_mealPlanEntries
Expand Down