Misc bunch of changes (#2815)

This commit is contained in:
Joe Milazzo 2024-03-23 16:20:16 -05:00 committed by GitHub
parent 18792b7b56
commit 63c9bff32e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
81 changed files with 4567 additions and 339 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace API.Data.Migrations
{
/// <inheritdoc />
public partial class UserMalToken : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "MalAccessToken",
table: "AspNetUsers",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "MalUserName",
table: "AspNetUsers",
type: "TEXT",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MalAccessToken",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "MalUserName",
table: "AspNetUsers");
}
}
}

View file

@ -97,6 +97,12 @@ namespace API.Data.Migrations
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("TEXT");
b.Property<string>("MalAccessToken")
.HasColumnType("TEXT");
b.Property<string>("MalUserName")
.HasColumnType("TEXT");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("TEXT");

View file

@ -5,8 +5,10 @@ using System.Text;
using System.Threading.Tasks;
using API.Data.ManualMigrations;
using API.DTOs;
using API.DTOs.Progress;
using API.Entities;
using API.Entities.Enums;
using API.Extensions.QueryExtensions;
using API.Services.Tasks.Scanner.Parser;
using AutoMapper;
using AutoMapper.QueryableExtensions;
@ -36,6 +38,7 @@ public interface IAppUserProgressRepository
Task<DateTime?> GetLatestProgressForSeries(int seriesId, int userId);
Task<DateTime?> GetFirstProgressForSeries(int seriesId, int userId);
Task UpdateAllProgressThatAreMoreThanChapterPages();
Task<IList<FullProgressDto>> GetUserProgressForChapter(int chapterId, int userId = 0);
}
#nullable disable
public class AppUserProgressRepository : IAppUserProgressRepository
@ -233,6 +236,33 @@ public class AppUserProgressRepository : IAppUserProgressRepository
await _context.Database.ExecuteSqlRawAsync(batchSql);
}
/// <summary>
///
/// </summary>
/// <param name="chapterId"></param>
/// <param name="userId">If 0, will pull all records</param>
/// <returns></returns>
public async Task<IList<FullProgressDto>> GetUserProgressForChapter(int chapterId, int userId = 0)
{
return await _context.AppUserProgresses
.WhereIf(userId > 0, p => p.AppUserId == userId)
.Where(p => p.ChapterId == chapterId)
.Include(p => p.AppUser)
.Select(p => new FullProgressDto()
{
AppUserId = p.AppUserId,
ChapterId = p.ChapterId,
PagesRead = p.PagesRead,
Id = p.Id,
Created = p.Created,
CreatedUtc = p.CreatedUtc,
LastModified = p.LastModified,
LastModifiedUtc = p.LastModifiedUtc,
UserName = p.AppUser.UserName
})
.ToListAsync();
}
#nullable enable
public async Task<AppUserProgress?> GetUserProgressAsync(int chapterId, int userId)
{