Skip to content

refactor: simplify code-example-evaluator route model loading#3701

Open
rohitpaulk wants to merge 1 commit intomainfrom
refactor-simplify-evaluator-route-model
Open

refactor: simplify code-example-evaluator route model loading#3701
rohitpaulk wants to merge 1 commit intomainfrom
refactor-simplify-evaluator-route-model

Conversation

@rohitpaulk
Copy link
Member

@rohitpaulk rohitpaulk commented Feb 4, 2026

Remove loading and filtering of evaluation subsets (pass, fail, unsure,
trusted) and drop helper methods for building filters and loading evaluations.
Load all languages instead of filtered languages. Streamline the model method
to simplify data requirements and reduce complexity. This change improves
maintainability by removing unused filtering logic and unused related types.


Note

Medium Risk
Changes the evaluation data-loading lifecycle from route model hooks to controller-managed async tasks, which can affect when/if results refresh on initial render and query-param changes.

Overview
Refactors the course-admin/code-example-evaluator page to simplify the route model and shift evaluation fetching into the controller. The route now only loads course, evaluator, allLanguages, and the parsed filter slugs, removing evaluation/trusted-evaluation types and the route’s filter/query helpers.

The controller now owns pass/fail/unsure evaluation lists as @tracked state and adds a loadEvaluationsTask that queries the store (plus trusted evaluations) in parallel and exposes an isLoadingEvaluations flag. The template switches to reading evaluations from controller state instead of @model.

Written by Cursor Bugbot for commit 431f831. This will update automatically on new commits. Configure here.

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Test Results

  1 files  ±0    1 suites  ±0   6m 48s ⏱️ +2s
700 tests ±0  643 ✅  - 2  55 💤 ±0  0 ❌ ±0  2 🔥 +2 
715 runs  ±0  656 ✅  - 4  55 💤 ±0  2 ❌ +2  2 🔥 +2 

For more details on these errors, see this check.

Results for commit 431f831. ± Comparison against base commit 156d356.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Feb 4, 2026

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
645 2 643 55
View the top 2 failed test(s) by shortest run time
Chrome 143.0::Acceptance | course-admin | view-code-example-evaluator: can view trusted evaluation for existing evaluation
Stack Traces | 0.445s run time
Promise rejected during "can view trusted evaluation for existing evaluation": Element not found.

PageObject: 'page.evaluationsSection.evaluationCards[0]'
  Selector: '[data-test-evaluations-section] [data-test-evaluation-card]:eq(0)'

PageObject: 'page.evaluationsSection.evaluationCards[0].click()'
  Selector: '[data-test-evaluations-section] [data-test-evaluation-card]:eq(0)'
Chrome 143.0::Acceptance | course-admin | view-code-example-evaluator: can create trusted evaluation for existing evaluation
Stack Traces | 0.482s run time
Promise rejected during "can create trusted evaluation for existing evaluation": Element not found.

PageObject: 'page.evaluationsSection.evaluationCards[0]'
  Selector: '[data-test-evaluations-section] [data-test-evaluation-card]:eq(0)'

PageObject: 'page.evaluationsSection.evaluationCards[0].click()'
  Selector: '[data-test-evaluations-section] [data-test-evaluation-card]:eq(0)'

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@action
async handleDidInsert() {
await this.loadEvaluationsTask.perform();
}
Copy link

Choose a reason for hiding this comment

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

handleDidInsert method is never called from template

High Severity

The handleDidInsert method is defined to trigger loadEvaluationsTask, but there is no corresponding {{did-insert this.handleDidInsert}} modifier in the template. This means the evaluations are never fetched, leaving the passEvaluations, failEvaluations, and unsureEvaluations arrays permanently empty.

Fix in Cursor Fix in Web

@cursor
Copy link

cursor bot commented Feb 4, 2026

Bugbot Autofix prepared fixes for 2 of the 2 bugs found in the latest run.

  • ✅ Fixed: Template references removed model properties, evaluations undefined
    • Changed template to use controller's tracked properties (this.passEvaluations, this.failEvaluations, this.unsureEvaluations) instead of removed model properties.
  • ✅ Fixed: handleDidInsert method is never called from template
    • Added {{did-insert this.handleDidInsert}} modifier to the root div element to trigger the loadEvaluationsTask when the template is inserted.

Create PR

Or push these changes by commenting:

@cursor push ab009fed8e
Preview (ab009fed8e)
diff --git a/app/templates/course-admin/code-example-evaluator.hbs b/app/templates/course-admin/code-example-evaluator.hbs
--- a/app/templates/course-admin/code-example-evaluator.hbs
+++ b/app/templates/course-admin/code-example-evaluator.hbs
@@ -1,4 +1,4 @@
-<div class="bg-white dark:bg-gray-950 min-h-screen">
+<div class="bg-white dark:bg-gray-950 min-h-screen" {{did-insert this.handleDidInsert}}>
   <div class="container mx-auto pt-4 pb-32 px-6">
     <div class="py-3 border-b border-gray-200 dark:border-white/5 mb-6">
       <TertiaryLinkButton @route="course-admin.code-example-evaluators" @models={{array @model.course.slug}} @size="small" class="pl-1.5 mb-3">
@@ -56,9 +56,9 @@
 
       <CourseAdmin::CodeExampleEvaluatorPage::EvaluationsSection
         @evaluator={{@model.evaluator}}
-        @passEvaluations={{@model.passEvaluations}}
-        @failEvaluations={{@model.failEvaluations}}
-        @unsureEvaluations={{@model.unsureEvaluations}}
+        @passEvaluations={{this.passEvaluations}}
+        @failEvaluations={{this.failEvaluations}}
+        @unsureEvaluations={{this.unsureEvaluations}}
         class="mt-8"
       />
     </div>

@codecov
Copy link

codecov bot commented Feb 4, 2026

Bundle Report

Changes will increase total bundle size by 932 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
client-array-push 39.04MB 932 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/chunk.*.js 932 bytes 213.32kB 0.44%

Files in assets/chunk.*.js:

  • ./controllers/course-admin/code-example-evaluator.ts → Total Size: 9.02kB

  • ./routes/course-admin/code-example-evaluator.ts → Total Size: 2.38kB

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issues.

@action
async handleDidInsert() {
await this.loadEvaluationsTask.perform();
}
Copy link

Choose a reason for hiding this comment

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

Evaluations don't reload when query params change

High Severity

The loadEvaluationsTask is only triggered via handleDidInsert, which fires once when the element is inserted. The route has refreshModel: true for languages and course_stage_slugs query params, so the model updates when filters change, but the controller's task won't re-run. Previously, evaluations were loaded in the route's model() hook, which ran on every query param change. Now, changing language or course stage filters won't refresh the evaluations list.

Fix in Cursor Fix in Web

@cursor
Copy link

cursor bot commented Feb 4, 2026

Bugbot Autofix prepared fixes for 2 of the 2 bugs found in the latest run.

  • ✅ Fixed: Template references removed model properties, evaluations never load
    • Added did-insert modifier to trigger handleDidInsert and changed template to use controller's tracked properties (this.passEvaluations, etc.) instead of the removed model properties.
  • ✅ Fixed: Evaluations don't reload when query params change
    • Added did-update modifier watching @model to re-run loadEvaluationsTask when the model changes due to query param changes (refreshModel: true).

Create PR

Or push these changes by commenting:

@cursor push 54931e2d67
Preview (54931e2d67)
diff --git a/app/templates/course-admin/code-example-evaluator.hbs b/app/templates/course-admin/code-example-evaluator.hbs
--- a/app/templates/course-admin/code-example-evaluator.hbs
+++ b/app/templates/course-admin/code-example-evaluator.hbs
@@ -1,4 +1,4 @@
-<div class="bg-white dark:bg-gray-950 min-h-screen">
+<div class="bg-white dark:bg-gray-950 min-h-screen" {{did-insert this.handleDidInsert}} {{did-update this.handleDidInsert @model}}>
   <div class="container mx-auto pt-4 pb-32 px-6">
     <div class="py-3 border-b border-gray-200 dark:border-white/5 mb-6">
       <TertiaryLinkButton @route="course-admin.code-example-evaluators" @models={{array @model.course.slug}} @size="small" class="pl-1.5 mb-3">
@@ -56,9 +56,9 @@
 
       <CourseAdmin::CodeExampleEvaluatorPage::EvaluationsSection
         @evaluator={{@model.evaluator}}
-        @passEvaluations={{@model.passEvaluations}}
-        @failEvaluations={{@model.failEvaluations}}
-        @unsureEvaluations={{@model.unsureEvaluations}}
+        @passEvaluations={{this.passEvaluations}}
+        @failEvaluations={{this.failEvaluations}}
+        @unsureEvaluations={{this.unsureEvaluations}}
         class="mt-8"
       />
     </div>

Remove loading and filtering of evaluation subsets (pass, fail, unsure,
trusted) and drop helper methods for building filters and loading evaluations.
Load all languages instead of filtered languages. Streamline the model method
to simplify data requirements and reduce complexity. This change improves
maintainability by removing unused filtering logic and unused related types.
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.

1 participant