128 refactor sessions to be session instances#135
Conversation
amberchow8
left a comment
There was a problem hiding this comment.
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).
| export const CustomizedSession = model<ICustomizedSession>( | ||
| "CustomizedSession", | ||
| customizedSessionSchema |
There was a problem hiding this comment.
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.
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