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;

public sealed partial class LearningActivityService(
    TikuDbContext dbContext,
    IQuestionReferenceService questionReferenceService,
    IPublicQuestionAccessPolicy publicQuestionAccessPolicy,
    ITenantExecutionScope tenantExecutionScope,
    ILogger<LearningActivityService> logger) : ILearningActivityService
{
    private const int DefaultLimit = 100;
    private const int MaxLimit = 500;
    private static readonly Meter LearningMeter = new("Tiku.Learning");

    private static readonly Counter<long> IdempotencyReplays =
        LearningMeter.CreateCounter<long>("tiku.learning.idempotency.replays");

    private static readonly Counter<long> AnswerConflicts =
        LearningMeter.CreateCounter<long>("tiku.learning.answer.conflicts");

    private static readonly Counter<long> SubmissionConflicts =
        LearningMeter.CreateCounter<long>("tiku.learning.submission.conflicts");

    private static readonly Counter<long> ScoringFailures =
        LearningMeter.CreateCounter<long>("tiku.learning.scoring.failures");
}