Skip to content

128 refactor sessions to be session instances#135

Open
arath7 wants to merge 4 commits into
mainfrom
128-refactor-sessions-to-be-session-instances
Open

128 refactor sessions to be session instances#135
arath7 wants to merge 4 commits into
mainfrom
128-refactor-sessions-to-be-session-instances

Conversation

@arath7

@arath7 arath7 commented Dec 5, 2024

Copy link
Copy Markdown
Collaborator

backend changes to create session model, modify sessionSchema to be similar to customizedBattery and modify variantSchema

@arath7 arath7 linked an issue Dec 5, 2024 that may be closed by this pull request

@amberchow8 amberchow8 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A CustomizedSession should have an id, name, and the original session that it is taken from instead of the properties that a CustomizedBattery has. I think we need to discuss with Christine about how a CustomizedSession would work (like if the tasks inside a CustomizedSession can be changed or not).

Comment thread packages/api/src/models/study.ts Outdated
Comment on lines +97 to +99
export const CustomizedSession = model<ICustomizedSession>(
"CustomizedSession",
customizedSessionSchema

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can create the Session model using the existing sessionSchema on line 23 (see below)

const sessionSchema = new Schema({
name: { type: String, required: true },
tasks: [taskInstanceSchema],
});

export const CustomizedSession = model(
"CustomizedSession",
sessionSchema
);

Comment thread packages/shared/types/models/study.ts Outdated
Comment on lines +43 to +61

export interface CreateOptionValue {
_id?: Types.ObjectId;
option: Types.ObjectId;
value: unknown;
}

export type IOptionValue = Required<CreateOptionValue>;

export interface CreateCustomizedSession {
_id?: Types.ObjectId;
battery: Types.ObjectId;
name: string;
values: CreateOptionValue[];
}

export interface ICustomizedSession extends Required<CreateCustomizedSession> {
values: IOptionValue[];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can get rid of these because creating sessions will remain the same as before, it uses CreateSession/ISession from lines 10-18. We will need to add CreateSessionInstance/ISessionInstance interfaces like how CreateTaskInstance/ITaskInstance is done. CreateSessionInstance will have an optional id and the ObjectId of the session it points to.

@amberchow8

Copy link
Copy Markdown
Contributor

One more thing we have to do is modify endpoints and logic for saving a study. We will need to create endpoints to create and update a Session document. The front end logic will have to be modified to call these endpoints when sessions are created/updated on the UI and the study data that gets passed when saving a study will need to be changed to include session object ids too.

@arath7 arath7 self-assigned this Feb 10, 2025
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.

Refactor sessions to be session instances

2 participants