Looks like we finally have a solution.
Change logging to just log a message, instead of the exception. Moved logic to Syncer involvement. When posting the data, if a 500 is returned, then it is up to the Syncer to re-submit it.
This commit is contained in:
parent
73955353cb
commit
004c490dd8
23 changed files with 529 additions and 177 deletions
|
|
@ -34,24 +34,21 @@ public static class PlaylistEndpoint
|
|||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation("Playlist {id} does not exist, adding it to the database", playlist._id);
|
||||
await repository.AddAsync(playlist, ct);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
logger.LogError(ex, "Failed to create Playlist {playlist}", playlist._id);
|
||||
logger.LogError("Failed to create Playlist {playlist}", playlist._id);
|
||||
return Results.StatusCode(500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add Update Code here
|
||||
logger.LogInformation("Playlist {id} exists, updating the databsae.", playlist._id);
|
||||
results.UpdateFrom(playlist);
|
||||
var toRemove = results.videos.Where(vid => !playlist.videos.Any(x => x.playlistItemId == vid.playlistItemId)).ToList();
|
||||
|
||||
results.lastUpdatedAt = playlist.lastUpdatedAt;
|
||||
results.@protected = playlist.@protected;
|
||||
results.playlistName = playlist.playlistName;
|
||||
results.createdAt = playlist.createdAt;
|
||||
|
||||
foreach (var vid in toRemove)
|
||||
results.videos.Remove(vid);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue