Push filtering, sorting and pagination into the database layer
Nobody has claimed this yet.
- 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-21—GetAllAsyncLearnStack.Core/Services/LearningResourceService.cs:74-96—UrlExistsAsyncmaterializes all URLsLearnStack/Components/Pages/Resources.razor:636-643— in-memory pagingLearnStack/Components/Pages/Pulse.razor.cs:60— loads all resources for aggregates
Proposed fix
- Introduce a query/filter object and return a paged result (
Items,TotalCount) from the service. - Apply search, status/type/priority filters, sorting and
Skip/TakeinIQueryable. - Add a persisted
NormalizedUrlcolumn with a unique index per user, and replaceUrlExistsAsyncwith a single indexed lookup. - Compute Pulse aggregates with
GroupByin 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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