mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-21 14:30:33 -04:00
* Introduced a new claim on the Token to get UserId as well as Username, thus allowing for many places of reduced DB calls. All users will need to reauthenticate. Introduced UTC Dates throughout the application, they are not exposed in all DTOs, that will come later when we fully switch over. For now, Utc dates will be updated along side timezone specific dates. Refactored get-progress/progress api to be 50% faster by reducing how much data is loaded from the query. * Speed up the following apis: collection/search, download/bookmarks, reader/bookmark-info, recommended/quick-reads, recommended/quick-catchup-reads, recommended/highly-rated, recommended/more-in, recommended/rediscover, want-to-read/ * Added a migration to sync all dates with their new UTC counterpart. * Added LastReadingProgressUtc onto ChapterDto for some browsing apis, but not all. Added LastReadingProgressUtc to reading list items. Refactored the migration to run raw SQL which is much faster. * Added LastReadingProgressUtc onto ChapterDto for some browsing apis, but not all. Added LastReadingProgressUtc to reading list items. Refactored the migration to run raw SQL which is much faster. * Fixed the unit tests * Fixed an issue with auto mapper which was causing progress page number to not get sent to UI * series/volume has chapter last reading progress * Added filesize and library name on reading list item dto for CDisplayEx. * Some minor code cleanup * Forgot to fill a field
173 lines
5.0 KiB
C#
173 lines
5.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using API.Data.Metadata;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Entities.Metadata;
|
|
using API.Extensions;
|
|
using API.Parser;
|
|
using API.Services.Tasks;
|
|
|
|
namespace API.Data;
|
|
|
|
/// <summary>
|
|
/// Responsible for creating Series, Volume, Chapter, MangaFiles for use in <see cref="ScannerService"/>
|
|
/// </summary>
|
|
public static class DbFactory
|
|
{
|
|
public static Series Series(string name)
|
|
{
|
|
return new Series
|
|
{
|
|
Name = name,
|
|
OriginalName = name,
|
|
LocalizedName = name,
|
|
NormalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(name),
|
|
NormalizedLocalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(name),
|
|
SortName = name,
|
|
Volumes = new List<Volume>(),
|
|
Metadata = SeriesMetadata(new List<CollectionTag>())
|
|
};
|
|
}
|
|
|
|
public static Series Series(string name, string localizedName)
|
|
{
|
|
if (string.IsNullOrEmpty(localizedName))
|
|
{
|
|
localizedName = name;
|
|
}
|
|
return new Series
|
|
{
|
|
Name = name,
|
|
OriginalName = name,
|
|
LocalizedName = localizedName,
|
|
NormalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(name),
|
|
NormalizedLocalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(localizedName),
|
|
SortName = name,
|
|
Volumes = new List<Volume>(),
|
|
Metadata = SeriesMetadata(new List<CollectionTag>())
|
|
};
|
|
}
|
|
|
|
public static Volume Volume(string volumeNumber)
|
|
{
|
|
return new Volume()
|
|
{
|
|
Name = volumeNumber,
|
|
Number = (int) Services.Tasks.Scanner.Parser.Parser.MinNumberFromRange(volumeNumber),
|
|
Chapters = new List<Chapter>()
|
|
};
|
|
}
|
|
|
|
public static Chapter Chapter(ParserInfo info)
|
|
{
|
|
var specialTreatment = info.IsSpecialInfo();
|
|
var specialTitle = specialTreatment ? info.Filename : info.Chapters;
|
|
return new Chapter()
|
|
{
|
|
Number = specialTreatment ? "0" : Services.Tasks.Scanner.Parser.Parser.MinNumberFromRange(info.Chapters) + string.Empty,
|
|
Range = specialTreatment ? info.Filename : info.Chapters,
|
|
Title = (specialTreatment && info.Format == MangaFormat.Epub)
|
|
? info.Title
|
|
: specialTitle,
|
|
Files = new List<MangaFile>(),
|
|
IsSpecial = specialTreatment,
|
|
};
|
|
}
|
|
|
|
public static SeriesMetadata SeriesMetadata(ICollection<CollectionTag> collectionTags)
|
|
{
|
|
return new SeriesMetadata()
|
|
{
|
|
CollectionTags = collectionTags,
|
|
Summary = string.Empty
|
|
};
|
|
}
|
|
|
|
public static CollectionTag CollectionTag(int id, string title, string summary, bool promoted)
|
|
{
|
|
return new CollectionTag()
|
|
{
|
|
Id = id,
|
|
NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(title?.Trim()),
|
|
Title = title?.Trim(),
|
|
Summary = summary?.Trim(),
|
|
Promoted = promoted,
|
|
SeriesMetadatas = new List<SeriesMetadata>()
|
|
};
|
|
}
|
|
|
|
public static ReadingList ReadingList(string title, string summary, bool promoted)
|
|
{
|
|
return new ReadingList()
|
|
{
|
|
NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(title?.Trim()),
|
|
Title = title?.Trim(),
|
|
Summary = summary?.Trim(),
|
|
Promoted = promoted,
|
|
Items = new List<ReadingListItem>()
|
|
};
|
|
}
|
|
|
|
public static ReadingListItem ReadingListItem(int index, int seriesId, int volumeId, int chapterId)
|
|
{
|
|
return new ReadingListItem()
|
|
{
|
|
Order = index,
|
|
ChapterId = chapterId,
|
|
SeriesId = seriesId,
|
|
VolumeId = volumeId
|
|
};
|
|
}
|
|
|
|
public static Genre Genre(string name)
|
|
{
|
|
return new Genre()
|
|
{
|
|
Title = name.Trim().SentenceCase(),
|
|
NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(name),
|
|
};
|
|
}
|
|
|
|
public static Tag Tag(string name)
|
|
{
|
|
return new Tag()
|
|
{
|
|
Title = name.Trim().SentenceCase(),
|
|
NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(name),
|
|
};
|
|
}
|
|
|
|
public static Person Person(string name, PersonRole role)
|
|
{
|
|
return new Person()
|
|
{
|
|
Name = name.Trim(),
|
|
NormalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(name),
|
|
Role = role
|
|
};
|
|
}
|
|
|
|
public static MangaFile MangaFile(string filePath, MangaFormat format, int pages)
|
|
{
|
|
return new MangaFile()
|
|
{
|
|
FilePath = filePath,
|
|
Format = format,
|
|
Pages = pages,
|
|
LastModified = File.GetLastWriteTime(filePath),
|
|
LastModifiedUtc = File.GetLastWriteTimeUtc(filePath),
|
|
};
|
|
}
|
|
|
|
public static Device Device(string name)
|
|
{
|
|
return new Device()
|
|
{
|
|
Name = name,
|
|
};
|
|
}
|
|
|
|
}
|