Skip to content

Commit

Permalink
fix: remove session creation
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Lauber <jan.lauber@protonmail.ch>
  • Loading branch information
janlauber committed Nov 7, 2023
1 parent 696e073 commit f6c8a3d
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions kubelab-ui/src/lib/stores/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,25 @@ export async function updateDataStores(filter: UpdateFilter = { filter: UpdateFi
console.log(error);
});

if (get(lab_sessions).length < get(labs).length) {
// only create lab_sessions for labs that are not already in lab_sessions
const filtered_labs = get(labs).filter(
(lab) => !get(lab_sessions).find((lab_session) => lab_session.lab === lab.id)
);

for (const lab of filtered_labs) {
const data = {
user: client.authStore.model?.id,
lab: lab.id,
clusterRunning: false
};
const record: LabSessionsResponse = await client
.collection("lab_sessions")
.create(data);
// update lab_sessions
lab_sessions.update((lab_sessions) => [...lab_sessions, record]);
}
}
// if (get(lab_sessions).length < get(labs).length) {
// // only create lab_sessions for labs that are not already in lab_sessions
// const filtered_labs = get(labs).filter(
// (lab) => !get(lab_sessions).find((lab_session) => lab_session.lab === lab.id)
// );

// for (const lab of filtered_labs) {
// const data = {
// user: client.authStore.model?.id,
// lab: lab.id,
// clusterRunning: false
// };
// const record: LabSessionsResponse = await client
// .collection("lab_sessions")
// .create(data);
// // update lab_sessions
// lab_sessions.update((lab_sessions) => [...lab_sessions, record]);
// }
// }

// get exercises and set exercises store
await client
Expand Down Expand Up @@ -188,28 +188,28 @@ export async function updateDataStores(filter: UpdateFilter = { filter: UpdateFi
});

// if exercise_sessions is empty, create exercise_sessions for each exercise
if (get(exercise_sessions).length < get(exercises).length) {
// only create exercise_sessions for exercises that are not already in exercise_sessions
const filtered_exercises = get(exercises).filter(
(exercise) =>
!get(exercise_sessions).find(
(exercise_session) => exercise_session.exercise === exercise.id
)
);

for (const exercise of filtered_exercises) {
const data = {
user: client.authStore.model?.id,
exercise: exercise.id,
clusterRunning: false
};
const record: ExerciseSessionsResponse = await client
.collection("exercise_sessions")
.create(data);
// update exercise_sessions
exercise_sessions.update((exercise_sessions) => [...exercise_sessions, record]);
}
}
// if (get(exercise_sessions).length < get(exercises).length) {
// // only create exercise_sessions for exercises that are not already in exercise_sessions
// const filtered_exercises = get(exercises).filter(
// (exercise) =>
// !get(exercise_sessions).find(
// (exercise_session) => exercise_session.exercise === exercise.id
// )
// );

// for (const exercise of filtered_exercises) {
// const data = {
// user: client.authStore.model?.id,
// exercise: exercise.id,
// clusterRunning: false
// };
// const record: ExerciseSessionsResponse = await client
// .collection("exercise_sessions")
// .create(data);
// // update exercise_sessions
// exercise_sessions.update((exercise_sessions) => [...exercise_sessions, record]);
// }
// }
}

export async function setLabStartTime(labSessionId: string) {
Expand Down

0 comments on commit f6c8a3d

Please sign in to comment.