Skip to content

Commit f8c8354

Browse files
allow pagination for API
1 parent 51cfc1d commit f8c8354

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ApiController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ namespace GithubActionsOrchestrator;
77
public class ApiController : Controller
88
{
99
[Route("get-runners")]
10-
public async Task<IResult> GetRunners()
10+
public async Task<IResult> GetRunners([FromQuery] int limit = 100, [FromQuery] int offset = 0)
1111
{
1212
var db = new ActionsRunnerContext();
13-
var recentRunners = await db.Runners.Include(x => x.Lifecycle).Include(x => x.Job).OrderByDescending(x => x.RunnerId).Take(100).ToListAsync();
13+
var recentRunners = await db.Runners.Include(x => x.Lifecycle).Include(x => x.Job).OrderByDescending(x => x.RunnerId).Skip(offset).Take(limit).ToListAsync();
1414
return Results.Json(recentRunners);
1515
}
1616

1717
[Route("get-jobs")]
18-
public async Task<IResult> GetJobs()
18+
public async Task<IResult> GetJobs([FromQuery] int limit = 100, [FromQuery] int offset = 0)
1919
{
2020
var db = new ActionsRunnerContext();
21-
var recentRunners = await db.Jobs.OrderByDescending(x => x.JobId).Take(100).ToListAsync();
21+
var recentRunners = await db.Jobs.OrderByDescending(x => x.JobId).Skip(offset).Take(limit).ToListAsync();
2222
return Results.Json(recentRunners);
2323
}
2424

0 commit comments

Comments
 (0)