Added ChangeLog

Added change log to track updates to the database, for easier pinging
from Syncer client.
This commit is contained in:
Mario Steele 2025-07-31 12:57:47 -05:00
parent fab306c393
commit c3cd7b5a16
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,29 @@
using FreeTubeSync.Database;
using FreeTubeSync.Model.Database;
namespace FreeTubeSync.EndPoints;
public static class PingEndpoint
{
public static void MapPingEndpoints(this WebApplication app)
{
var group = app.MapGroup("ping");
group.MapGet("/", async (CancellationToken token) =>
{
await Task.Delay(10);
var dict = new { AppVersion = "0.1.3" };
return Results.Ok(dict);
});
group.MapGet("/lastUpdated", async (DataContext dbContext, CancellationToken token) =>
{
var log = await dbContext.GetLatestChangeAsync(token);
if (log == null)
return Results.NotFound();
var dict = new { LastUpdated = log.ChangeTime };
return Results.Ok(dict);
});
}
}

View file

@ -0,0 +1,9 @@
namespace FreeTubeSync.Model.Database;
public class ChangeLog
{
public int Id { get; set; }
public string TableName { get; set; } = string.Empty;
public string ChangeType { get; set; } = string.Empty;
public DateTime ChangeTime { get; set; } = DateTime.MinValue;
}