Skip to content

Commit

Permalink
feat: get sync tasks support filter by repoId
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka-L committed Aug 30, 2024
1 parent 8a4bc3d commit 71b340b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ await defaultDbContext.SyncTasks
.SetProperty(task => task.EndTime, endTime => currentDateTime));
}

public async ValueTask<SyncTaskEntity[]> GetSyncTasksAsync(int offset = 0, int limit = 20)
public async ValueTask<SyncTaskEntity[]> GetSyncTasksAsync(int offset = 0, int limit = 20, string? repoId = null)
{
return await defaultDbContext.SyncTasks
.Where(task => repoId == null || task.RepoId == repoId)
.OrderByDescending(task => task.Id)
.Skip(offset)
.Take(limit)
Expand Down
4 changes: 2 additions & 2 deletions VPMReposSynchronizer.Entry/Controllers/SyncTaskController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class SyncTaskController(
IMapper mapper) : ControllerBase
{
[HttpGet]
public async Task<SyncTaskPublic[]> Index([Range(0, int.MaxValue)] int offset = 0, [Range(1, 100)] int limit = 20)
public async Task<SyncTaskPublic[]> Index([Range(0, int.MaxValue)] int offset = 0, [Range(1, 100)] int limit = 20, string? repoId = null)
{
var syncTasks = await repoSyncTaskService.GetSyncTasksAsync(offset, limit);
var syncTasks = await repoSyncTaskService.GetSyncTasksAsync(offset, limit, repoId);

return mapper.Map<SyncTaskPublic[]>(syncTasks);
}
Expand Down

0 comments on commit 71b340b

Please sign in to comment.