Skip to content

Commit

Permalink
fix: disappearing courses when changed (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
jxjj authored Sep 17, 2024
1 parent 57d4f8c commit 0f00b12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions app/CourseSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ public function enrollments() {
}

public function getApiId(): string {
// note: we're using a id field that remains fixed for the record
// even after updates to avoid issues when a user changes the term
// or course or instructor
return join('-',[
$this->getCourseApiId(),
$this->class_section,
$this->term_id
'local-db',
$this->id,
]);
}

Expand Down
9 changes: 6 additions & 3 deletions app/Enrollment.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ public function user() {
}

public function getApiId(): string {
return join('_', [
$this->user->emplid,
$this->courseSection->getApiId(),
// note: we're using a id field that remains fixed for the record
// even after updates to avoid issues when a user changes the term
// or course or instructor
return join('-', [
'local-db',
$this->id,
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
// expect that the unofficial section is included
$sectionFromApi = collect($res->json())->firstWhere('courseId', $section->course_id);
expect($sectionFromApi)->toEqual([
'id' => "TEST-1234-{$section->class_section}-{$section->term_id}",
'id' => "local-db-{$section->id}",
'dbId' => $section->id,
'courseId' => $section->course_id,
'termId' => $section->term_id,
Expand Down

0 comments on commit 0f00b12

Please sign in to comment.