UTC Dates + CDisplayEx API Enhancements (#1781)
* 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
This commit is contained in:
parent
36b48404c1
commit
7616eb5b0f
58 changed files with 3003 additions and 131 deletions
|
@ -11,7 +11,9 @@ namespace API.Entities;
|
|||
public class AppUser : IdentityUser<int>, IHasConcurrencyToken
|
||||
{
|
||||
public DateTime Created { get; set; } = DateTime.Now;
|
||||
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
|
||||
public DateTime LastActive { get; set; }
|
||||
public DateTime LastActiveUtc { get; set; }
|
||||
public ICollection<Library> Libraries { get; set; }
|
||||
public ICollection<AppUserRole> UserRoles { get; set; }
|
||||
public ICollection<AppUserProgress> Progresses { get; set; }
|
||||
|
@ -60,4 +62,10 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
|
|||
RowVersion++;
|
||||
}
|
||||
|
||||
public void UpdateLastActive()
|
||||
{
|
||||
LastActive = DateTime.Now;
|
||||
LastActiveUtc = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,4 +27,6 @@ public class AppUserBookmark : IEntityDate
|
|||
public int AppUserId { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ public class AppUserProgress : IEntityDate
|
|||
/// </summary>
|
||||
public DateTime LastModified { get; set; }
|
||||
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
|
||||
// Relationships
|
||||
/// <summary>
|
||||
/// Navigational Property for EF. Links to a unique AppUser
|
||||
|
|
|
@ -24,6 +24,9 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate
|
|||
public ICollection<MangaFile> Files { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Relative path to the (managed) image file representing the cover image
|
||||
/// </summary>
|
||||
|
@ -101,6 +104,7 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate
|
|||
public ICollection<Genre> Genres { get; set; } = new List<Genre>();
|
||||
public ICollection<Tag> Tags { get; set; } = new List<Tag>();
|
||||
|
||||
public ICollection<AppUserProgress> UserProgress { get; set; }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,15 @@ public class Device : IEntityDate
|
|||
/// Last time this device was used to send a file
|
||||
/// </summary>
|
||||
public DateTime LastUsed { get; set; }
|
||||
public DateTime LastUsedUtc { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
|
||||
public void UpdateLastUsed()
|
||||
{
|
||||
LastUsed = DateTime.Now;
|
||||
LastUsedUtc = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,16 @@ public class FolderPath
|
|||
// Relationship
|
||||
public Library Library { get; set; }
|
||||
public int LibraryId { get; set; }
|
||||
|
||||
public void UpdateLastScanned(DateTime? time)
|
||||
{
|
||||
if (time == null)
|
||||
{
|
||||
LastScanned = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastScanned = (DateTime) time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,4 +6,6 @@ public interface IEntityDate
|
|||
{
|
||||
DateTime Created { get; set; }
|
||||
DateTime LastModified { get; set; }
|
||||
DateTime CreatedUtc { get; set; }
|
||||
DateTime LastModifiedUtc { get; set; }
|
||||
}
|
||||
|
|
|
@ -33,6 +33,9 @@ public class Library : IEntityDate
|
|||
public bool ManageCollections { get; set; } = true;
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Last time Library was scanned
|
||||
/// </summary>
|
||||
|
@ -42,4 +45,21 @@ public class Library : IEntityDate
|
|||
public ICollection<AppUser> AppUsers { get; set; }
|
||||
public ICollection<Series> Series { get; set; }
|
||||
|
||||
public void UpdateLastModified()
|
||||
{
|
||||
LastModified = DateTime.Now;
|
||||
LastModifiedUtc = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public void UpdateLastScanned(DateTime? time)
|
||||
{
|
||||
if (time == null)
|
||||
{
|
||||
LastScanned = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastScanned = (DateTime) time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,10 +36,15 @@ public class MangaFile : IEntityDate
|
|||
/// </summary>
|
||||
/// <remarks>This gets updated anytime the file is scanned</remarks>
|
||||
public DateTime LastModified { get; set; }
|
||||
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Last time file analysis ran on this file
|
||||
/// </summary>
|
||||
public DateTime LastFileAnalysis { get; set; }
|
||||
public DateTime LastFileAnalysisUtc { get; set; }
|
||||
|
||||
|
||||
// Relationship Mapping
|
||||
|
@ -53,5 +58,12 @@ public class MangaFile : IEntityDate
|
|||
public void UpdateLastModified()
|
||||
{
|
||||
LastModified = File.GetLastWriteTime(FilePath);
|
||||
LastModifiedUtc = File.GetLastWriteTimeUtc(FilePath);
|
||||
}
|
||||
|
||||
public void UpdateLastFileAnalysis()
|
||||
{
|
||||
LastFileAnalysis = DateTime.Now;
|
||||
LastFileAnalysisUtc = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ public class ReadingList : IEntityDate
|
|||
public ICollection<ReadingListItem> Items { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
|
||||
// Relationships
|
||||
public int AppUserId { get; set; }
|
||||
|
|
|
@ -19,5 +19,4 @@ public class ReadingListItem
|
|||
public Series Series { get; set; }
|
||||
public Volume Volume { get; set; }
|
||||
public Chapter Chapter { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ public class Series : IEntityDate, IHasReadTimeEstimate
|
|||
/// Whenever a modification occurs. Ie) New volumes, removed volumes, title update, etc
|
||||
/// </summary>
|
||||
public DateTime LastModified { get; set; }
|
||||
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Absolute path to the (managed) image file
|
||||
/// </summary>
|
||||
|
@ -64,6 +68,10 @@ public class Series : IEntityDate, IHasReadTimeEstimate
|
|||
/// </summary>
|
||||
public DateTime LastFolderScanned { get; set; }
|
||||
/// <summary>
|
||||
/// Last time the folder was scanned in Utc
|
||||
/// </summary>
|
||||
public DateTime LastFolderScannedUtc { get; set; }
|
||||
/// <summary>
|
||||
/// The type of all the files attached to this series
|
||||
/// </summary>
|
||||
public MangaFormat Format { get; set; } = MangaFormat.Unknown;
|
||||
|
@ -76,6 +84,7 @@ public class Series : IEntityDate, IHasReadTimeEstimate
|
|||
/// When a Chapter was last added onto the Series
|
||||
/// </summary>
|
||||
public DateTime LastChapterAdded { get; set; }
|
||||
public DateTime LastChapterAddedUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total Word count of all chapters in this chapter.
|
||||
|
@ -104,4 +113,16 @@ public class Series : IEntityDate, IHasReadTimeEstimate
|
|||
public List<Volume> Volumes { get; set; }
|
||||
public Library Library { get; set; }
|
||||
public int LibraryId { get; set; }
|
||||
|
||||
public void UpdateLastFolderScanned()
|
||||
{
|
||||
LastFolderScanned = DateTime.Now;
|
||||
LastFolderScannedUtc = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public void UpdateLastChapterAdded()
|
||||
{
|
||||
LastChapterAdded = DateTime.Now;
|
||||
LastChapterAddedUtc = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,4 +35,6 @@ public class SiteTheme : IEntityDate, ITheme
|
|||
public ThemeProvider Provider { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ public class Volume : IEntityDate, IHasReadTimeEstimate
|
|||
public IList<Chapter> Chapters { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Absolute path to the (managed) image file
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue