8000 Yuqiang/student dashboard loading issue by smallst · Pull Request #8016 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Yuqiang/student dashboard loading issue #8016

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

smallst
Copy link
Contributor
@smallst smallst commented Jun 15, 2025

fix ENG-1865
optimize by 2 steps.

  1. do not wait for level sessions fetch. actually progress is not so important in student page. the most important thing in student home page is button/link to the course-campaign page. we fetch the session in campaign page again. So if the network is slow, we should allow student to access campaign page without waiting for all course-sessions.
    example page when sessions is not loaded:
    image

  2. when fething instance-sessions, we actually share progress for same language classrooms. so if courseID and language is same, we don't need fetch sessions twice. consider level.session is slowest, reduce even 1 request is better. Esp in china some student join many 'python' classrooms for custom tournaments. (we do not have esports classroom before).

Summary by CodeRabbit

  • Refactor
    • Improved the clarity and efficiency of course and classroom loading, grouping, and rendering in the courses view.
    • Updated logic for displaying course instances and "play next level" buttons to better handle cases where no sessions exist and to streamline conditional checks.
  • Style
    • Minor syntactical adjustments for consistency (trailing comma removals/additions) with no impact on functionality.

Copy link
Contributor
coderabbitai bot commented Jun 15, 2025

Walkthrough

The changes involve syntactic adjustments to object literals in several files, restructuring of template logic for rendering course instances and next level buttons, and an optimization in session fetching by grouping course instances by language and course ID. No exported or public entity signatures are altered.

Changes

File(s) Change Summary
app/core/store/modules/courseInstances.js, app/views/courses/TeacherClassView.js, app/views/courses/TeacherClassesView.js Minor syntactic changes to object literals (addition/removal of trailing commas) in internal method implementations.
app/templates/courses/courses-view.pug Refactored template logic for rendering course instances and next level button; improved conditional checks and flow.
app/views/courses/CoursesView.js Optimized session fetching by grouping course instances by language/course ID; improved loading state management.

Sequence Diagram(s)

sequenceDiagram
    participant Teacher as TeacherClassesView
    participant CourseInstance
    participant CoursesView
    participant SessionsCollection

    Teacher->>CourseInstance: Create new instance (with aceConfig)
    CoursesView->>CourseInstance: Group by language & course ID
    loop For each group
        CoursesView->>SessionsCollection: Fetch sessions (per language/course)
        SessionsCollection-->>CourseInstance: Assign sessions to all in group
    end
    CoursesView->>CoursesView: Render course-instance entries
Loading

Suggested reviewers

  • mrfinch

Poem

A hop, a skip, a code refactor,
Commas trimmed, the logic's crisper.
Sessions grouped by tongue and course,
Buttons show with clearer force.
With every tweak, this bunny cheers,
For code that’s neat brings coder ears! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the 8000 error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: 'treema@0.0.0',
npm warn EBADENGINE required: { node: '0.8.x' },
npm warn EBADENGINE current: { node: 'v24.2.0', npm: '11.3.0' }
npm warn EBADENGINE }
npm warn skipping integrity check for git dependency ssh://git@github.com/codecombat/treema.git
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-18T07_55_21_433Z-debug-0.log

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ENG-1865: Authentication required, not authenticated - You need to authenticate to access this operation.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5296deb and 8877fe8.

📒 Files selected for processing (4)
  • app/core/store/modules/courseInstances.js (1 hunks)
  • app/views/courses/CoursesView.js (5 hunks)
  • app/views/courses/TeacherClassView.js (1 hunks)
  • app/views/courses/TeacherClassesView.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/views/courses/TeacherClassesView.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/core/store/modules/courseInstances.js
  • app/views/courses/TeacherClassView.js
  • app/views/courses/CoursesView.js
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ESLint CI
  • GitHub Check: Node.js CI (20.19.2)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
app/core/store/modules/courseInstances.js (1)

156-159: aceConfig object is re-created on every invocation – consider reuse / merge.

aceConfig is now initialised with { language: classroom.aceConfig?.language }.
Two follow-ups:

  1. language may still be undefined for legacy classrooms. In that case we end up persisting { language: undefined }, which clutters the document without adding value.
  2. If more fields are later added to classroom.aceConfig, they will be silently dropped here because we always build a fresh object instead of cloning / shallow-merging.
-  aceConfig: {
-    language: classroom.aceConfig?.language,
-  }
+  // Preserve any existing aceConfig keys and only overwrite missing values
+  aceConfig: {
+    ...classroom.aceConfig,
+    language: classroom.aceConfig?.language ?? null
+  }
app/views/courses/TeacherClassView.js (1)

775-778: Potentially undefined this.classroom.language.

this.classroom.language is only set once the classroom finishes syncing (line 113).
If a teacher hits “Assign” before the first sync event returns, language will be undefined and we store { language: undefined } inside the instance, mirroring the issue mentioned in the store module.

Either gate the call until the classroom is synced or fall back to this.classroom.get('aceConfig')?.language.

app/views/courses/CoursesView.js (1)

374-383: Share one fetched collection, but beware of mutation.

All instances in a (language, course) bucket receive the exact same collection reference.
If any code later mutates instance.sessions.models (e.g., via reset), it mutates them for every sibling instance.
Add a comment or freeze the collection to avoid surprising side-effects.

app/templates/courses/courses-view.pug (1)

304-337: Dynamic ‘play next level’ tile lacks click handler when disabled.

When nextLevelLocked is true the anchor is rendered with disabled attribute but still as <a>. Browsers don’t natively honour disabled on anchors – the link remains focusable / clickable.

Consider:

-if view.nextLevelInfo
-  a.play-next-level-btn.tile(disabled=nextLevelLocked …
+if view.nextLevelInfo
+  - var tag = nextLevelLocked ? 'div' : 'a'
+  #{tag}.play-next-level-btn.tile(class=nextLevelLocked ? 'disabled' : '', href=nextLevelLocked ? null : view.nextLevelUrl())

Or attach pointer-events: none via CSS to .disabled.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44f4399 and ed1a172.

📒 Files selected for processing (4)
  • app/core/store/modules/courseInstances.js (1 hunks)
  • app/templates/courses/courses-view.pug (3 hunks)
  • app/views/courses/CoursesView.js (3 hunks)
  • app/views/courses/TeacherClassView.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ESLint CI
🔇 Additional comments (1)
app/templates/courses/courses-view.pug (1)

181-218: Indentation / flow control may break Pug compile.

Inside the if nextLevel block the subsequent if view.utils.isCodeCombat line is preceded by an extra space (␠if). Pug treats leading spaces as indentation; mis-alignment can raise a “Block in mixin expected” error.

Verify that this chunk compiles:

if nextLevel
  - var isNextLevelLocked = …
  …
  if view.utils.isCodeCombat
    +course-instance-body(…)
  else
    +course-instance-body(…)

Remove stray spa 8000 ces before control keywords.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (2)
app/views/courses/ClassroomView.js (1)

115-124: ⚠️ Potential issue

Incorrect reference: sessions points to the wrong collection

Inside the JIT course-instance generation block, the line

sessions.courseInstance = courseInstance

mutates the last sessions collection created in the previous loop, not the brand-new empty collection you just assigned to courseInstance.sessions. This silently links two unrelated objects and will surface as confusing bugs (wrong courseInstance on a session, duplicated listeners, etc.).

Patch:

-            courseInstance.sessions = new CocoCollection([], { model: LevelSession })
-            sessions.courseInstance = courseInstance
+            courseInstance.sessions = new CocoCollection([], { model: LevelSession })
+            courseInstance.sessions.courseInstance = courseInstance
app/views/courses/TeacherClassesView.js (1)

261-263: 🛠️ Refactor suggestion

Existing promise construction is fragile

Not introduced in this diff, but while you’re here: promises.push(new Promise(courseInstance.save(...).then)) creates a Promise with an executor equal to whatever .then returns (likely undefined)—this is a no-op and breaks error handling. Prefer pushing the jqXHR (which is a thenable) or wrap it explicitly:

-                promises.push(new Promise(courseInstance.save(null, { validate: false }).then))
+                promises.push(courseInstance.save(null, { validate: false }))
🧹 Nitpick comments (1)
app/views/courses/TeacherClassesView.js (1)

254-259: Language config added, but watch the trailing comma

The new aceConfig block is correct; however, the trailing comma after the language property produces aceConfig: { language: undefined, } when the classroom lacks the key. While harmless in most engines, we don’t use trailing commas elsewhere in this file—drop it for consistency.

-                  aceConfig: {
-                    language: classroom.get('aceConfig')?.language,
-                  },
+                  aceConfig: {
+                    language: classroom.get('aceConfig')?.language
+                  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed1a172 and a4bcd60.

📒 Files selected for processing (2)
  • app/views/courses/ClassroomView.js (1 hunks)
  • app/views/courses/TeacherClassesView.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/views/courses/ClassroomView.js (1)
app/views/courses/ 8000 TeacherClassesView.js (2)
  • courseInstance (251-251)
  • CourseInstance (26-26)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ESLint CI
  • GitHub Check: Node.js CI (20.19.2)
🔇 Additional comments (1)
app/views/courses/ClassroomView.js (1)

115-120: 👍 Consistent propagation of language via aceConfig

Adding the classroom’s aceConfig.language when synthesising a CourseInstance keeps the object graph consistent with the rest of the refactor and removes several runtime look-ups. Looks good.

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
0