Refactoring, database structure changed

This commit is contained in:
2025-03-03 00:56:32 +01:00
Unverified
parent d3805ef3db
commit c603c41c0b
913 changed files with 21764 additions and 32775 deletions

View File

@@ -0,0 +1,30 @@
using WatchIt.Database.Model;
namespace WatchIt.DTO.Models.Generics.ViewCount;
public static class ViewCountMappers
{
#region PUBLIC METHODS
public static ViewCountResponse ToResponse(this IEnumerable<IViewCountEntity> viewCounts)
{
IEnumerable<IViewCountEntity> viewCountEntities = viewCounts.ToList();
return new ViewCountResponse
{
Last24Hours = viewCountEntities.CountFrom(DateTime.Now.AddDays(-1)),
LastWeek = viewCountEntities.CountFrom(DateTime.Now.AddDays(-7)),
LastMonth = viewCountEntities.CountFrom(DateTime.Now.AddMonths(-1)),
LastYear = viewCountEntities.CountFrom(DateTime.Now.AddYears(-1)),
};
}
#endregion
#region PRIVATE METHODS
private static long CountFrom(this IEnumerable<IViewCountEntity> viewCounts, DateTime date) => viewCounts.Where(x => x.Date >= DateOnly.FromDateTime(date)).Sum(x => x.ViewCount);
#endregion
}

View File

@@ -0,0 +1,13 @@
namespace WatchIt.DTO.Models.Generics.ViewCount;
public class ViewCountResponse
{
#region PROPERTIES
public long Last24Hours { get; set; }
public long LastWeek { get; set; }
public long LastMonth { get; set; }
public long LastYear { get; set; }
#endregion
}