-
Notifications
You must be signed in to change notification settings - Fork 0
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
128 refactor sessions to be session instances #135
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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).
packages/api/src/models/study.ts
Outdated
export const CustomizedSession = model<ICustomizedSession>( | ||
"CustomizedSession", | ||
customizedSessionSchema |
There was a problem hiding this comment.
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
);
|
||
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[]; | ||
} |
There was a problem hiding this comment.
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.
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. |
backend changes to create session model, modify sessionSchema to be similar to customizedBattery and modify variantSchema