添加项目文件。
This commit is contained in:
50
TightWiki.Repository/StatisticsRepository.cs
Normal file
50
TightWiki.Repository/StatisticsRepository.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using TightWiki.Models.DataModels;
|
||||
|
||||
namespace TightWiki.Repository
|
||||
{
|
||||
public static class StatisticsRepository
|
||||
{
|
||||
public static void InsertCompilationStatistics(int pageId,
|
||||
double wikifyTimeMs, int matchCount, int errorCount, int outgoingLinkCount,
|
||||
int tagCount, int processedBodySize, int bodySize)
|
||||
{
|
||||
var param = new
|
||||
{
|
||||
CreatedDate = DateTime.UtcNow,
|
||||
PageId = pageId,
|
||||
WikifyTimeMs = wikifyTimeMs,
|
||||
MatchCount = matchCount,
|
||||
ErrorCount = errorCount,
|
||||
OutgoingLinkCount = outgoingLinkCount,
|
||||
TagCount = tagCount,
|
||||
ProcessedBodySize = processedBodySize,
|
||||
BodySize = bodySize
|
||||
};
|
||||
|
||||
ManagedDataStorage.Statistics.Execute("InsertCompilationStatistics.sql", param);
|
||||
}
|
||||
|
||||
public static void PurgeCompilationStatistics()
|
||||
=> ManagedDataStorage.Statistics.Execute("PurgeCompilationStatistics.sql");
|
||||
|
||||
public static List<PageCompilationStatistics> GetCompilationStatisticsPaged(
|
||||
int pageNumber, string? orderBy = null, string? orderByDirection = null, int? pageSize = null)
|
||||
{
|
||||
pageSize ??= ConfigurationRepository.Get<int>("Customization", "Pagination Size");
|
||||
|
||||
var param = new
|
||||
{
|
||||
PageSize = pageSize,
|
||||
PageNumber = pageNumber
|
||||
};
|
||||
|
||||
return ManagedDataStorage.Statistics.Ephemeral(o =>
|
||||
{
|
||||
using var users_db = o.Attach("pages.db", "pages_db");
|
||||
|
||||
var query = RepositoryHelper.TransposeOrderby("GetCompilationStatisticsPaged.sql", orderBy, orderByDirection);
|
||||
return o.Query<PageCompilationStatistics>(query, param).ToList();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user