kasuken / kasuken/LearnStack

Push filtering, sorting and pagination into the database layer

Open
#47 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
HTML
Stars
10
Forks
0
Avg merge
2h 52m
Merged PRs (30d)
20

Description

Tier 2 — scale

Problem

GetAllAsync(userId) loads a user's entire library into memory (thumbnails included); the component then filters, sorts and pages it client-side. UrlExistsAsync loads every URL a user owns just to compare one. Pulse loads everything to compute aggregates. This is fine at 50 resources and collapses at 5,000.

Evidence
  • LearnStack.Core/Services/LearningResourceService.cs:12-21GetAllAsync
  • LearnStack.Core/Services/LearningResourceService.cs:74-96UrlExistsAsync materializes all URLs
  • LearnStack/Components/Pages/Resources.razor:636-643 — in-memory paging
  • LearnStack/Components/Pages/Pulse.razor.cs:60 — loads all resources for aggregates
Proposed fix
  1. Introduce a query/filter object and return a paged result (Items, TotalCount) from the service.
  2. Apply search, status/type/priority filters, sorting and Skip/Take in IQueryable.
  3. Add a persisted NormalizedUrl column with a unique index per user, and replace UrlExistsAsync with a single indexed lookup.
  4. Compute Pulse aggregates with GroupBy in SQL rather than in memory.
Acceptance criteria
  • Resource list issues one query per page regardless of library size
  • Duplicate-URL check is a single indexed query
  • Pulse does not materialize the full library

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading LearnStack.Core/Services/LearningResourceService.cs:12-21 and :74-96, then inspect Resources.razor:636-643 and Pulse.razor.cs:60. Trace how the current in-memory operations work before introducing the query/filter and paged-result design. Done means one query per resource-list page, one indexed duplicate-URL lookup, and no full-library materialization for Pulse aggregates.

Written by the indexing model from the issue text.

Assessment

Domain
backend, database
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.