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

Be 345 related lessons #73

Merged
merged 3 commits into from
Oct 9, 2024
Merged

Be 345 related lessons #73

merged 3 commits into from
Oct 9, 2024

Conversation

roxanariza
Copy link
Contributor

The fetchRelatedLessons function provide related lessons for a specific content item,constructing a dynamic query that accounts for multiple relationship scenarios and sorting rules. Here’s a breakdown of how the related lessons are fetched and organized:

  • Child Lessons: Lessons that are direct children of the specified content (railContentId). These lessons are fetched with metadata like title, difficulty level, artist, and permission IDs.

  • Lessons by Artist (Same Type): Songs of the same type and brand where the artist matches that of the specified content. The lessons exclude the current railContentId and are ordered by published_on (descending) and title (ascending). The result is limited to 10 lessons.

  • Lessons by Genre (Same Type): Songs of the same type and brand where the genre matches that of the specified content. These lessons are also ordered by published_on (descending) and title (ascending), excluding the current railContentId and limited to 10 results.

  • Same Type with Custom Sort (by episode number): Lessons of the same type, where the type is listed in a predefined set (typeWithSortOrder). These lessons are sorted by the custom sort field (ascending), followed by title (ascending), limited to 10 results.

  • Same Type with Default Sort (by published-on): Lessons of the same type, but not in the typeWithSortOrder list. These are sorted by published_on (descending) and title (ascending). The result is limited to 10 lessons.

Each related lesson type is fetched uniquely and combined using array::unique to prevent duplicates. The total number of related lessons is limited to 10.

Copy link
Contributor

@BrandonKerr BrandonKerr left a comment

Choose a reason for hiding this comment

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

Looks good!

@roxanariza roxanariza merged commit 9c02ace into main Oct 9, 2024
1 check passed
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.

2 participants