Added ChangeLog
Added change log to track updates to the database, for easier pinging from Syncer client.
This commit is contained in:
parent
fab306c393
commit
c3cd7b5a16
2 changed files with 38 additions and 0 deletions
29
FreeTubeSync/EndPoints/PingEndpoint.cs
Normal file
29
FreeTubeSync/EndPoints/PingEndpoint.cs
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
9
FreeTubeSync/Model/Database/ChangeLog.cs
Normal file
9
FreeTubeSync/Model/Database/ChangeLog.cs
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue