Browse Source

Update method signature

pull/19380/head
Salih 2 years ago
parent
commit
ecd55789d8
  1. 2
      modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs
  2. 3
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs
  3. 5
      modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs
  4. 5
      modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs
  5. 4
      modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocumentRepository_Tests.cs

2
modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs

@ -70,7 +70,7 @@ namespace Volo.Docs.Admin.Documents
await _documentUpdateCache.RemoveManyAsync(documentUpdateInfoCacheKeys);
await _documentRepository.ClearCachesAsync(project.Id);
await _documentRepository.UpdateProjectLastCachedTimeAsync(project.Id, DateTime.MinValue);
}
public virtual async Task PullAllAsync(PullAllDocumentInput input)

3
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs

@ -13,7 +13,8 @@ namespace Volo.Docs.Documents
Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default);
Task ClearCachesAsync(Guid projectId, CancellationToken cancellationToken = default);
Task UpdateProjectLastCachedTimeAsync(Guid projectId, DateTime cachedTime,
CancellationToken cancellationToken = default);
Task<Document> FindAsync(Guid projectId,
string name,

5
modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs

@ -56,9 +56,10 @@ namespace Volo.Docs.Documents
return await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task ClearCachesAsync(Guid projectId, CancellationToken cancellationToken = default)
public async Task UpdateProjectLastCachedTimeAsync(Guid projectId, DateTime cachedTime,
CancellationToken cancellationToken = default)
{
await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ExecuteUpdateAsync(x => x.SetProperty(d => d.LastCachedTime, DateTime.MinValue), GetCancellationToken(cancellationToken));
await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ExecuteUpdateAsync(x => x.SetProperty(d => d.LastCachedTime, cachedTime), GetCancellationToken(cancellationToken));
}
public virtual async Task<List<Document>> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default)

5
modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs

@ -54,12 +54,13 @@ namespace Volo.Docs.Documents
return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task ClearCachesAsync(Guid projectId, CancellationToken cancellationToken = default)
public async Task UpdateProjectLastCachedTimeAsync(Guid projectId, DateTime cachedTime,
CancellationToken cancellationToken = default)
{
var collection = await GetCollectionAsync(cancellationToken);
await collection.UpdateManyAsync(
Builders<Document>.Filter.Eq(x => x.ProjectId, projectId),
Builders<Document>.Update.Set(x => x.LastCachedTime, DateTime.MinValue),
Builders<Document>.Update.Set(x => x.LastCachedTime, cachedTime),
cancellationToken: GetCancellationToken(cancellationToken)
);
}

4
modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocumentRepository_Tests.cs

@ -37,9 +37,9 @@ namespace Volo.Docs
}
[Fact]
public async Task ClearCachesAsync()
public async Task UpdateProjectLastCachedTimeAsync()
{
await DocumentRepository.ClearCachesAsync(DocsTestData.ProjectId);
await DocumentRepository.UpdateProjectLastCachedTimeAsync(DocsTestData.ProjectId, DateTime.MinValue);
var documentsAfterClear = await DocumentRepository.GetListByProjectId(DocsTestData.ProjectId);
documentsAfterClear.ForEach(d => d.LastCachedTime.ShouldBe(DateTime.MinValue));
}

Loading…
Cancel
Save