Implemented scheduling service and first two jobs

This commit is contained in:
2026-10-28 17:01:28 +02:00
parent 6114d8f457
commit 7f686fa8c6
20 changed files with 304 additions and 112 deletions
@@ -42,7 +42,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Domain.Models.Activity[]>> GetActivitiesAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Domain.Models.Activity[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetActivitiesAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getactivities-{projectIdHash}").Value;
@@ -66,7 +66,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Domain.Models.Activity>> GetActivityAsync(string activityIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Domain.Models.Activity>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetActivityAsync(activityIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getactivity-{activityIdHash}").Value;
@@ -90,7 +90,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Beneficiary[]>> GetBeneficiariesAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Beneficiary[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetBeneficiariesAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getbeneficiaries-{projectIdHash}").Value;
@@ -114,7 +114,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Beneficiary>> GetBeneficiaryAsync(string beneficiaryIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Beneficiary>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetBeneficiaryAsync(beneficiaryIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getbeneficiary-{beneficiaryIdHash}").Value;
@@ -138,7 +138,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<ChangeRequest>> GetChangeRequestAsync(string changeRequestIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<ChangeRequest>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetChangeRequestAsync(changeRequestIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getchangerequest-{changeRequestIdHash}").Value;
@@ -162,7 +162,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<ChangeRequest[]>> GetChangeRequestsAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<ChangeRequest[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetChangeRequestsAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getchangerequests-{projectIdHash}").Value;
@@ -186,7 +186,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<ComplianceItem>> GetComplianceItemAsync(string complianceItemIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<ComplianceItem>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetComplianceItemAsync(complianceItemIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getcomplianceitem-{complianceItemIdHash}").Value;
@@ -210,7 +210,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<ComplianceItem[]>> GetComplianceItemsAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<ComplianceItem[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetComplianceItemsAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getcomplianceitems-{projectIdHash}").Value;
@@ -234,7 +234,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Issue>> GetIssueAsync(string issueIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Issue>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetIssueAsync(issueIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getissue-{issueIdHash}").Value;
@@ -258,7 +258,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Issue[]>> GetIssuesAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Issue[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetIssuesAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getissues-{projectIdHash}").Value;
@@ -282,7 +282,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Milestone>> GetMilestoneAsync(string milestoneIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Milestone>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetMilestoneAsync(milestoneIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getmilestone-{milestoneIdHash}").Value;
@@ -306,7 +306,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Milestone[]>> GetMilestonesAsync(Pagination pagination, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Milestone[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetMilestonesAsync(pagination, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getmilestones-{pagination.Index}-{pagination.PageSize}-{pagination.Page}").Value;
@@ -330,7 +330,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Outcome>> GetOutcomeAsync(string outcomeIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Outcome>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetOutcomeAsync(outcomeIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getoutcome-{outcomeIdHash}").Value;
@@ -354,7 +354,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Outcome[]>> GetOutcomesAsync(string beneficiaryIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Outcome[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetOutcomesAsync(beneficiaryIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getoutcomes-{beneficiaryIdHash}").Value;
@@ -378,7 +378,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Outcome[]>> GetProjectOutcomesAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Outcome[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProjectOutcomesAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getprojectoutcomes-{projectIdHash}").Value;
@@ -402,7 +402,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Programme>> GetProgrammeAsync(string programmeIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Programme>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProgrammeAsync(programmeIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getprogramme-{programmeIdHash}").Value;
@@ -426,7 +426,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Project[]>> GetProgrammeProjectsAsync(string programmeIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Project[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProgrammeProjectsAsync(programmeIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getprogrammeprojects-{programmeIdHash}").Value;
@@ -450,7 +450,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Programme[]>> GetProgrammesAsync(Pagination pagination, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Programme[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProgrammesAsync(pagination, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getprogrammes-{pagination.Index}-{pagination.PageSize}-{pagination.Page}").Value;
@@ -474,7 +474,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Project>> GetProjectAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Project>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProjectAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getproject-{projectIdHash}").Value;
@@ -498,7 +498,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Indicator[]>> GetProjectIndicatorsAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Indicator[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProjectIndicatorsAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getprojectindicators-{projectIdHash}").Value;
@@ -522,7 +522,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Milestone[]>> GetProjectMilestonesAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Milestone[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProjectMilestonesAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getprojectmilestones-{projectIdHash}").Value;
@@ -546,7 +546,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Risk[]>> GetProjectRisksAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Risk[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProjectRisksAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getprojectrisks-{projectIdHash}").Value;
@@ -570,7 +570,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<Project[]>> GetProjectsAsync(Pagination pagination, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Project[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetProjectsAsync(pagination, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getprojects-{pagination.Index}-{pagination.Page}-{pagination.PageSize}").Value;
@@ -594,7 +594,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<SiteVisit>> GetSiteVisitAsync(string siteVisitIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<SiteVisit>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetSiteVisitAsync(siteVisitIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getsitevisit-{siteVisitIdHash}").Value;
@@ -618,7 +618,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result<SiteVisit[]>> GetSiteVisitsAsync(string projectIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<SiteVisit[]>>>)(async () =>
{
if (!await featureManager.IsEnabledAsync(ServiceCachingFeature))
if (!await featureManager.IsEnabledAsync(FeatureServiceCaching))
return await service.GetSiteVisitsAsync(projectIdHash, cancellationToken);
var cacheKey = HashService.ToMd5Hash($"getsitevisits-{projectIdHash}").Value;