41 lines
1.8 KiB
C#
41 lines
1.8 KiB
C#
using System.Diagnostics.Metrics;
|
|
using Microsoft.Extensions.Logging;
|
|
using Tiku.Application.Learning;
|
|
using Tiku.Application.QuestionBanks;
|
|
using Tiku.Application.Security;
|
|
using Tiku.Infrastructure.Persistence;
|
|
|
|
namespace Tiku.Infrastructure.Learning;
|
|
|
|
internal sealed record LearningServiceDependencies(
|
|
TikuDbContext DbContext,
|
|
IQuestionReferenceService QuestionReferenceService,
|
|
IPublicQuestionAccessPolicy PublicQuestionAccessPolicy,
|
|
ITenantExecutionScope TenantExecutionScope,
|
|
ILogger<LearningActivityServiceBase> Logger);
|
|
|
|
internal abstract partial class LearningActivityServiceBase(LearningServiceDependencies dependencies)
|
|
{
|
|
protected TikuDbContext dbContext { get; } = dependencies.DbContext;
|
|
protected IQuestionReferenceService questionReferenceService { get; } = dependencies.QuestionReferenceService;
|
|
protected IPublicQuestionAccessPolicy publicQuestionAccessPolicy { get; } = dependencies.PublicQuestionAccessPolicy;
|
|
protected ITenantExecutionScope tenantExecutionScope { get; } = dependencies.TenantExecutionScope;
|
|
protected ILogger<LearningActivityServiceBase> logger { get; } = dependencies.Logger;
|
|
|
|
protected const int DefaultLimit = 100;
|
|
protected const int MaxLimit = 500;
|
|
protected static readonly Meter LearningMeter = new("Tiku.Learning");
|
|
|
|
protected static readonly Counter<long> IdempotencyReplays =
|
|
LearningMeter.CreateCounter<long>("tiku.learning.idempotency.replays");
|
|
|
|
protected static readonly Counter<long> AnswerConflicts =
|
|
LearningMeter.CreateCounter<long>("tiku.learning.answer.conflicts");
|
|
|
|
protected static readonly Counter<long> SubmissionConflicts =
|
|
LearningMeter.CreateCounter<long>("tiku.learning.submission.conflicts");
|
|
|
|
protected static readonly Counter<long> ScoringFailures =
|
|
LearningMeter.CreateCounter<long>("tiku.learning.scoring.failures");
|
|
}
|