Wire NowPlayingStats to live aggregates: add SQL track duration column, stats endpoint, and duration backfill
This commit is contained in:
@@ -236,6 +236,46 @@ public class TrackManager
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<HomeStatsDto>> GetHomeStats(CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var stats = await Repository.GetHomeStatsAsync(cancellationToken);
|
||||
return ResultContainer<HomeStatsDto>.CreatePassResult(stats);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return ResultContainer<HomeStatsDto>.CreateFailResult(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<List<TrackDto>>> GetTracksMissingDuration(CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var entities = await Repository.GetTracksMissingDurationAsync(cancellationToken);
|
||||
return ResultContainer<List<TrackDto>>.CreatePassResult(
|
||||
entities.Select(TrackConverter.Convert).ToList());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return ResultContainer<List<TrackDto>>.CreateFailResult(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<int>> UpdateDuration(long id, double durationSeconds, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var updated = await Repository.UpdateDurationAsync(id, durationSeconds, cancellationToken);
|
||||
return ResultContainer<int>.CreatePassResult(updated);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return ResultContainer<int>.CreateFailResult(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<TrackDto>> Create(TrackDto newTrack)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user