Skip to content

Commit

Permalink
misc: expose created/updated timestamps for episode/group in APIv3
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Jan 1, 2025
1 parent ae8f31e commit db935d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Shoko.Server/API/v3/Models/Shoko/Episode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ public class Episode : BaseModel
/// </summary>
public Rating? UserRating { get; set; }

/// <summary>
/// The time when the episode was created.
/// </summary>
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTime Created { get; set; }

/// <summary>
/// The time when the episode was last updated,
/// </summary>
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTime Updated { get; set; }

#pragma warning disable IDE1006
/// <summary>
/// The <see cref="Episode.AniDB"/>, if <see cref="DataSource.AniDB"/> is
Expand Down Expand Up @@ -163,6 +175,8 @@ public Episode(HttpContext context, SVR_AnimeEpisode episode, HashSet<DataSource
Name = episode.PreferredTitle;
Description = episode.PreferredOverview;
Size = files.Count;
Created = episode.DateTimeCreated.ToUniversalTime();
Updated = episode.DateTimeUpdated.ToUniversalTime();

if (vote is not null)
{
Expand Down
16 changes: 16 additions & 0 deletions Shoko.Server/API/v3/Models/Shoko/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Converters;
using Shoko.Commons.Extensions;
using Shoko.Plugin.Abstractions.Enums;
using Shoko.Server.API.v3.Helpers;
Expand Down Expand Up @@ -65,6 +67,18 @@ public class Group : BaseModel
/// </summary>
public GroupSizes Sizes { get; set; }

/// <summary>
/// The time when the group was created.
/// </summary>
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTime Created { get; set; }

/// <summary>
/// The time when the group was last updated
/// </summary>
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTime Updated { get; set; }

#region Constructors

public Group(SVR_AnimeGroup group, int userID = 0, bool randomizeImages = false)
Expand All @@ -86,6 +100,8 @@ public Group(SVR_AnimeGroup group, int userID = 0, bool randomizeImages = false)
Description = group.Description;
Sizes = ModelHelper.GenerateGroupSizes(allSeries, episodes, subGroupCount, userID);
Size = allSeries.Count(series => series.AnimeGroupID == group.AnimeGroupID);
Created = group.DateTimeCreated.ToUniversalTime();
Updated = group.DateTimeUpdated.ToUniversalTime();
HasCustomName = group.IsManuallyNamed == 1;
HasCustomDescription = group.OverrideDescription == 1;
Images = mainSeries == null ? new Images() : mainSeries.GetImages().ToDto(preferredImages: true, randomizeImages: randomizeImages);
Expand Down

0 comments on commit db935d3

Please sign in to comment.