Skip to content
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

feat(profile): limit language logos to 5 in course progress items #2705

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ryan-gang
Copy link
Contributor

@ryan-gang ryan-gang commented Feb 25, 2025

  • Display max 5 language logos per course progress item
  • Prioritize completed languages first
  • Sort by recency (completed or last submission date)
  • Show recent incomplete languages if fewer than 5 completed ones

Checklist:

  • I've thoroughly self-reviewed my changes
  • I've added tests for my changes, unless they affect admin-only areas (or are otherwise not worth testing)
  • I've verified any visual changes using Percy (add a commit with [percy] in the message to trigger)

Summary by CodeRabbit

  • New Features

    • Enhanced the course progress display on the user page to show a curated set of language icons. Now, up to five languages are presented by prioritizing the most recently completed courses with recent in-progress ones supplementing as needed.
  • Refactor

    • Streamlined the ordering and display logic to ensure a clearer and more relevant presentation of your language progress.

- Display max 5 language logos per course progress item
- Prioritize completed languages first
- Sort by recency (completed or last submission date)
- Show recent incomplete languages if fewer than 5 completed ones

🤖 Generated with Claude Code
Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

Walkthrough

This pull request updates the course progress list item component. The Handlebars template now iterates over a newly computed list, languagesToDisplay, instead of @courseParticipations. In the corresponding JavaScript file, a constant for the maximum number of languages (5) is defined, and a computed property is added to filter and sort both completed and incomplete course participations. The overall control flow remains unchanged, with only the data source for iteration being modified to provide a curated list of languages.

Changes

File(s) Change Summary
app/.../course-progress-list-item/index.hbs
app/.../course-progress-list-item/index.js
- Updated template to iterate over this.languagesToDisplay instead of @courseParticipations.
- Introduced MAX_LANGUAGES_TO_DISPLAY = 5 constant.
- Added computed property languagesToDisplay that sorts completed participations (by completion date descending) and, if needed, combines them with recent incomplete participations (by last submission date descending) ensuring a maximum of 5 items.

Sequence Diagram(s)

sequenceDiagram
    participant Component as CourseProgressListItemComponent
    participant Data as Participation Data
    participant Template as Handlebars Template
    participant Logo as LanguageLogo Component

    Component->>Data: Retrieve course participation data
    Data-->>Component: Return data set
    Component->>Component: Compute languagesToDisplay (sort & filter, limit to 5)
    Component-->>Template: Provide languagesToDisplay
    Template->>Template: Iterate over languagesToDisplay with "each"
    Template->>Logo: Render LanguageLogo with isCompleted check
Loading

Possibly related PRs

Suggested reviewers

  • rohitpaulk

Poem

In a burrow of code, I happily hop,
New languages bloom, reaching the top.
Sorted and filtered with care so neat,
Five little treasures now make output complete.
With each loop and check, my heart does leap—
Coding adventures, a joy to keep! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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

Test Results

  1 files  ±0    1 suites  ±0   6m 33s ⏱️ -5s
620 tests ±0  576 ✅ +1  44 💤 ±0  0 ❌ ±0 
620 runs  ±0  576 ✅ +2  44 💤 ±0  0 ❌  - 1 

Results for commit 14cf213. ± Comparison against base commit 3725717.

Copy link

codecov bot commented Feb 25, 2025

Bundle Report

Changes will increase total bundle size by 2.12kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
client-array-push 36.2MB 2.12kB (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/chunk.*.js 85 bytes 30.83kB 0.28%
assets/chunk.*.js 1 bytes 12.04kB 0.01%
assets/chunk.*.js 1 bytes 25.92kB 0.0%
assets/chunk.*.js 13 bytes 161.86kB 0.01%
assets/chunk.*.js -1 bytes 53.02kB -0.0%
assets/chunk.*.js -1 bytes 234.06kB -0.0%
assets/chunk.*.js 5 bytes 62.46kB 0.01%
assets/chunk.*.js 5 bytes 107.93kB 0.0%
assets/chunk.*.js 2.0kB 2.46MB 0.08%
assets/chunk.*.js 8 bytes 405.58kB 0.0%

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...nents/user-page/course-progress-list-item/index.js 77.77% 2 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

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: 1

🧹 Nitpick comments (1)
app/components/user-page/course-progress-list-item/index.js (1)

41-43: Consider adding a reusable date comparison function

The date comparison logic is duplicated in both sorting operations. Consider extracting this to a reusable helper function for better maintainability.

+ // Helper function for date comparisons
+ const compareByDate = (dateField) => (a, b) => 
+   new Date(b[dateField]).getTime() - new Date(a[dateField]).getTime();

  get languagesToDisplay() {
    // First, get all completed course participations sorted by completion time (most recent first)
-    const completedParticipations = this.completedCourseParticipations.sort(
-      (a, b) => new Date(b.completedAt).getTime() - new Date(a.completedAt).getTime()
-    );
+    const completedParticipations = this.completedCourseParticipations.sort(compareByDate('completedAt'));
    
    // Next, get incomplete participations sorted by activity time (most recent first)
    const incompleteParticipations = this.args.courseParticipations
      .filter(p => !p.isCompleted)
-      .sort((a, b) => new Date(b.lastSubmissionAt).getTime() - new Date(a.lastSubmissionAt).getTime());
+      .sort(compareByDate('lastSubmissionAt'));
🧰 Tools
🪛 ESLint

[error] 42-42: Insert ,

(prettier/prettier)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3725717 and 14cf213.

📒 Files selected for processing (2)
  • app/components/user-page/course-progress-list-item/index.hbs (1 hunks)
  • app/components/user-page/course-progress-list-item/index.js (2 hunks)
🧰 Additional context used
🪛 ESLint
app/components/user-page/course-progress-list-item/index.js

[error] 42-42: Insert ,

(prettier/prettier)


[error] 44-44: Delete ····

(prettier/prettier)


[error] 47-47: Replace p with (p)

(prettier/prettier)


[error] 49-49: Delete ····

(prettier/prettier)


[error] 54-54: Delete ····

(prettier/prettier)


[error] 56-59: Replace ⏎······...completedParticipations,⏎······...incompleteParticipations.slice(0,·MAX_LANGUAGES_TO_DISPLAY·-·completedParticipations.length)⏎···· with ...completedParticipations,·...incompleteParticipations.slice(0,·MAX_LANGUAGES_TO_DISPLAY·-·completedParticipations.length)

(prettier/prettier)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (3)
app/components/user-page/course-progress-list-item/index.hbs (1)

48-48: Good implementation of the language logo limitation requirement

The change from @courseParticipations to this.languagesToDisplay correctly implements the requirement to limit and prioritize language logos as specified in the PR objectives.

app/components/user-page/course-progress-list-item/index.js (2)

6-6: Good use of a named constant for the language limit

Using a constant MAX_LANGUAGES_TO_DISPLAY makes the code more maintainable and the intention clear.


46-48:

❓ Verification inconclusive

Verify that lastSubmissionAt is always present

The code assumes lastSubmissionAt is always available on incomplete participations. If this field could be null or undefined for new participations with no submissions, it might cause sorting issues.


🏁 Script executed:

#!/bin/bash
# Check if there are any course participations without lastSubmissionAt
rg -A2 -B2 "lastSubmissionAt" --include="*.js" --include="*.ts"

Length of output: 505


Action: Confirm that every incomplete course participation has a valid lastSubmissionAt value

  • The sorting logic in the component assumes that lastSubmissionAt is always present. If any participation is missing this field (i.e., it is null or undefined), sorting could produce unexpected results.
  • Please manually verify through your data source or schema definition that every incomplete course participation includes a valid lastSubmissionAt. If there's any chance that new participations might not have submissions (and thus lack this field), consider handling such cases (e.g., filtering them out or providing a default value) before sorting.
🧰 Tools
🪛 ESLint

[error] 47-47: Replace p with (p)

(prettier/prettier)

Comment on lines +39 to +60
get languagesToDisplay() {
// First, get all completed course participations sorted by completion time (most recent first)
const completedParticipations = this.completedCourseParticipations.sort(
(a, b) => new Date(b.completedAt).getTime() - new Date(a.completedAt).getTime()
);

// Next, get incomplete participations sorted by activity time (most recent first)
const incompleteParticipations = this.args.courseParticipations
.filter(p => !p.isCompleted)
.sort((a, b) => new Date(b.lastSubmissionAt).getTime() - new Date(a.lastSubmissionAt).getTime());

// If we have 5 or fewer completed participations, show all of them
if (completedParticipations.length >= MAX_LANGUAGES_TO_DISPLAY) {
return completedParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY);
}

// Otherwise, show all completed participations + recent incomplete ones (up to 5 total)
return [
...completedParticipations,
...incompleteParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY - completedParticipations.length)
];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Implementation correctly satisfies all requirements, but has formatting issues

The implementation correctly:

  1. Prioritizes completed languages
  2. Sorts by recency (completion date or last submission date)
  3. Displays incomplete languages if fewer than 5 completed ones exist

However, there are some formatting issues flagged by ESLint that should be fixed.

  get languagesToDisplay() {
    // First, get all completed course participations sorted by completion time (most recent first)
    const completedParticipations = this.completedCourseParticipations.sort(
-      (a, b) => new Date(b.completedAt).getTime() - new Date(a.completedAt).getTime()
+      (a, b) => new Date(b.completedAt).getTime() - new Date(a.completedAt).getTime(),
    );
    
    // Next, get incomplete participations sorted by activity time (most recent first)
    const incompleteParticipations = this.args.courseParticipations
-      .filter(p => !p.isCompleted)
+      .filter((p) => !p.isCompleted)
      .sort((a, b) => new Date(b.lastSubmissionAt).getTime() - new Date(a.lastSubmissionAt).getTime());
    
    // If we have 5 or fewer completed participations, show all of them
    if (completedParticipations.length >= MAX_LANGUAGES_TO_DISPLAY) {
      return completedParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY);
    }
    
    // Otherwise, show all completed participations + recent incomplete ones (up to 5 total)
-    return [
-      ...completedParticipations,
-      ...incompleteParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY - completedParticipations.length)
-    ];
+    return [...completedParticipations, ...incompleteParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY - completedParticipations.length)];
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
get languagesToDisplay() {
// First, get all completed course participations sorted by completion time (most recent first)
const completedParticipations = this.completedCourseParticipations.sort(
(a, b) => new Date(b.completedAt).getTime() - new Date(a.completedAt).getTime()
);
// Next, get incomplete participations sorted by activity time (most recent first)
const incompleteParticipations = this.args.courseParticipations
.filter(p => !p.isCompleted)
.sort((a, b) => new Date(b.lastSubmissionAt).getTime() - new Date(a.lastSubmissionAt).getTime());
// If we have 5 or fewer completed participations, show all of them
if (completedParticipations.length >= MAX_LANGUAGES_TO_DISPLAY) {
return completedParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY);
}
// Otherwise, show all completed participations + recent incomplete ones (up to 5 total)
return [
...completedParticipations,
...incompleteParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY - completedParticipations.length)
];
}
get languagesToDisplay() {
// First, get all completed course participations sorted by completion time (most recent first)
const completedParticipations = this.completedCourseParticipations.sort(
(a, b) => new Date(b.completedAt).getTime() - new Date(a.completedAt).getTime(),
);
// Next, get incomplete participations sorted by activity time (most recent first)
const incompleteParticipations = this.args.courseParticipations
.filter((p) => !p.isCompleted)
.sort((a, b) => new Date(b.lastSubmissionAt).getTime() - new Date(a.lastSubmissionAt).getTime());
// If we have 5 or fewer completed participations, show all of them
if (completedParticipations.length >= MAX_LANGUAGES_TO_DISPLAY) {
return completedParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY);
}
// Otherwise, show all completed participations + recent incomplete ones (up to 5 total)
return [...completedParticipations, ...incompleteParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY - completedParticipations.length)];
}
🧰 Tools
🪛 ESLint

[error] 42-42: Insert ,

(prettier/prettier)


[error] 44-44: Delete ····

(prettier/prettier)


[error] 47-47: Replace p with (p)

(prettier/prettier)


[error] 49-49: Delete ····

(prettier/prettier)


[error] 54-54: Delete ····

(prettier/prettier)


[error] 56-59: Replace ⏎······...completedParticipations,⏎······...incompleteParticipations.slice(0,·MAX_LANGUAGES_TO_DISPLAY·-·completedParticipations.length)⏎···· with ...completedParticipations,·...incompleteParticipations.slice(0,·MAX_LANGUAGES_TO_DISPLAY·-·completedParticipations.length)

(prettier/prettier)

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