Optimized db queries
This commit is contained in:
@@ -12,5 +12,11 @@ public class TimelineController(ITimelineRepository repository) : ControllerBase
|
||||
var timeline = await repository.GetTimeline(type, ct);
|
||||
return Ok(timeline);
|
||||
}
|
||||
|
||||
[HttpGet("featured")]
|
||||
public async Task<IActionResult> GetFeaturedTimeline(CancellationToken ct) {
|
||||
var timeline = await repository.GetFeaturedTimeline(ct);
|
||||
return Ok(timeline);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,5 +11,10 @@ internal sealed class TimelineRepository(DatabaseContext context) : ITimelineRep
|
||||
.Where(entry => entry.Type == type)
|
||||
.ToArrayAsync(ct);
|
||||
}
|
||||
|
||||
|
||||
public async Task<IEnumerable<TimelineEntry>> GetFeaturedTimeline(CancellationToken ct) {
|
||||
return await context.Timeline
|
||||
.Where(entry => entry.Featured)
|
||||
.ToArrayAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user