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

MVP data models for goals, subgoals(benchmarks), tasks. #157

Merged
merged 9 commits into from
Jul 27, 2023
Merged

Conversation

jonahchoi
Copy link
Contributor

@jonahchoi jonahchoi commented Jul 22, 2023

#90 :

  • Added tables for goals, subgoals, tasks, and collections
  • Added routes for IEP and para
  • Added some tests (not fully encompassing)
  • Modified frontend components to display new data

Worked with: @amantri @tessathornberry @hieungo89

Copy link
Contributor

@codetheweb codetheweb left a comment

Choose a reason for hiding this comment

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

can't speak much to the data model but implementation is looking pretty good :)

@@ -70,12 +71,44 @@ CREATE TABLE "goal" (
goal_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), -- TODO: add index to allow reordering
iep_id UUID REFERENCES "iep" (iep_id),
description TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
category TEXT NOT NULL CHECK (category IN ('writing', 'reading', 'math', 'other'))
Copy link
Contributor

Choose a reason for hiding this comment

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

🐧 convention has been to have "common" columns like created_at at the end of the table definition

);

CREATE TABLE "subgoal" (
subgoal_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), -- TODO: add index to allow reordering
goal_id UUID REFERENCES "goal" (goal_id),
description TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
instructions TEXT,
Copy link
Contributor

Choose a reason for hiding this comment

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

🐧 I'd probably make this not null and default to ""

src/backend/db/migrations/1_initial-migrations.sql Outdated Show resolved Hide resolved

-- Optional depending on type of task
notes TEXT,
image_list TEXT[]
Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't look like this is being used yet so I might remove it
this should point to file_ids, it's usually a bit of an antipattern to store arrays in sql

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 agree. I was thinking of having files reference trials, but kind of left it here as a placeholder since it wasn't essential yet. I'll remove it for now.

<form onSubmit={onSubmit} id="table_input_form"></form>
<form
onSubmit={(event: React.FormEvent<HTMLFormElement>) => {
onSubmit(event);
Copy link
Contributor

Choose a reason for hiding this comment

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

type for onSubmit should be updated above to return Promise<void> | void and then we can await it here to prevent resetting the form if onSubmit is async and throws

Comment on lines 295 to 296
const form = document.getElementById("table_input_form");
(form as HTMLFormElement).reset();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const form = document.getElementById("table_input_form");
(form as HTMLFormElement).reset();
event.target.reset()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I was playing around with this for Tessa's issue and forgot to remove it. But thank you for this optimization! I'll let Tessa know about it.

@@ -45,7 +45,8 @@ CREATE TABLE "student" (
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE,
assigned_case_manager_id UUID REFERENCES "user" (user_id) ON DELETE SET NULL
assigned_case_manager_id UUID REFERENCES "user" (user_id) ON DELETE SET NULL,
grade SMALLINT
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The newest mockups have grade on the student table and on students' pages. Although I forgot to implement it elsewhere. I can either a) remove it for now and let another issue handle it or b) write a todo comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

In general, try to keep a PR self contained that is focused on a specific feature/bug. This field would ideally be in the PR that adds that to the frontend/backend, but since you have already added it here, I will leave it to your discretion if you want to leave it in or remove it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Sometimes I think of something and just toss it in, but I'll try to keep things more self contained from now on.

created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE "subgoal" (
subgoal_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), -- TODO: add index to allow reordering
goal_id UUID REFERENCES "goal" (goal_id),
description TEXT NOT NULL,
instructions TEXT NOT NULL DEFAULT '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
instructions TEXT NOT NULL DEFAULT '',
instructions TEXT NOT NULL DEFAULT "",

Consistent quotes

Copy link
Contributor Author

@jonahchoi jonahchoi Jul 26, 2023

Choose a reason for hiding this comment

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

I tried this first, and found out that in SQL, single and double quotes actually have different meanings. Single quotes are for string literals, while double quotes are "delimited identifiers", meaning they reference tables or columns.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah - thanks for the info. TIL

created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE "subgoal" (
subgoal_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), -- TODO: add index to allow reordering
goal_id UUID REFERENCES "goal" (goal_id),
description TEXT NOT NULL,
instructions TEXT NOT NULL DEFAULT '',
target_max_attempts INTEGER, --How many "questions" to administer in a single sitting
Copy link
Contributor

Choose a reason for hiding this comment

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

This depends on the type of subgoal this is - e.g. quantitative vs behavioral.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's one reason I left it as an optional column. But I believe we discussed with Niko that our MVP would focus on one collection type, with plans to add more in the future. Maybe we can brainstorm better options for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

SG. Let's get this PR merged in, and we can update it later.

@@ -32,4 +42,13 @@ test("basic flow - add/get goals and subgoals", async (t) => {
goal_id: goal1!.goal_id,
});
t.is(gotSubgoals.length, 2);

t.truthy(
Copy link
Contributor

Choose a reason for hiding this comment

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

🐧 Ideally, we should be using our API methods instead of directly querying the db. We will likely need a getTasks method down the line when we want to do the Para schedule view. You can add a TODO for that now.

Copy link
Contributor

@amantri amantri left a comment

Choose a reason for hiding this comment

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

LGTM

@jonahchoi jonahchoi merged commit 82c6534 into main Jul 27, 2023
3 checks passed
jonahchoi added a commit that referenced this pull request Jul 28, 2023
* New task and data tables

* Added task and data tables. Edited paraDash and taskCards to use db

* Updated schemas

* Updated all paratrial schemas. Updated routes and components to reflect changes.

* Added new tests for para routes, adjusted test for iep route

* Adjusted schemas, removed unrelated code.

* Add todos in iep.test
@jonahchoi jonahchoi deleted the paraFlow branch August 7, 2023 23:58
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