Treat common and private registries separately

This commit is contained in:
2025-10-28 15:29:17 +09:00
parent 5e5880c367
commit c8686a5899
6 changed files with 23 additions and 15 deletions

View File

@ -5,9 +5,9 @@ namespace Hcs.WebApp.Services
{
public class RegistryService(IDbContextFactory<HcsDbContext> factory) : HcsServiceBase(factory)
{
public async Task<int> GetRegistryCountAsync(HcsDbContext context)
public async Task<int> GetRegistryCountAsync(HcsDbContext context, bool isCommon)
{
return await context.Registries.CountAsync();
return await context.Registries.CountAsync(x => x.IsCommon == isCommon);
}
public async Task<IEnumerable<Registry>> GetAllRegistriesAsync(bool isCommon)
@ -32,10 +32,16 @@ namespace Hcs.WebApp.Services
select registry).ToListAsync();
}
public async Task SetOperationsToRegistriesAsync(HcsDbContext context, IEnumerable<Operation> operations)
public async Task SetOperationsToRegistriesAsync(HcsDbContext context, bool isCommon, IEnumerable<Operation> operations)
{
var queue = new Queue<Operation>(operations);
await context.Registries.ForEachAsync(x => x.LastSyncOperationId = queue.Dequeue().Id);
await context.Registries.ForEachAsync(x =>
{
if (x.IsCommon == isCommon)
{
x.LastSyncOperationId = queue.Dequeue().Id;
}
});
await context.SaveChangesAsync();
}
}