Without this the weight is only reachable by editing the database, so the enumerator has nothing to distribute by. Weight is threaded through create and update (all four handler branches: add and update, plain and smart) and defaults to 1, so it is optional on the wire and /api/v1 stays additive under the freeze. It is returned on the read path too, which is load-bearing rather than symmetry: the update replaces the item list, so a client that GETs, edits a name, and PUTs back would silently reset every weight to the default if the GET didn't carry it. Weight edits ride the existing MultiCollection Version token, so If-Match/412 concurrency needs no new design. Regenerated v1.json + v1.d.ts + endpoint-index via update-openapi.sh and generate:api (never hand-edited). The spec picks up weight on both request and response models and WeightedShuffle in the PlaybackOrder enum; weight is emitted optional. Refs #70 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
23 lines
727 B
C#
23 lines
727 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using ErsatzTV.Application.MediaCollections;
|
|
|
|
namespace ErsatzTV.Controllers.Api.Requests;
|
|
|
|
public record UpdateMultiCollectionRequest(string Name, List<MultiCollectionItemRequest> Items)
|
|
{
|
|
public UpdateMultiCollection ToCommand(int id, Option<Seq<int>> expectedVersions = default) =>
|
|
new(
|
|
id,
|
|
Name,
|
|
(Items ?? new List<MultiCollectionItemRequest>())
|
|
.Select(i => new UpdateMultiCollectionItem(
|
|
i.CollectionId,
|
|
i.SmartCollectionId,
|
|
i.ScheduleAsGroup,
|
|
i.PlaybackOrder,
|
|
i.Weight))
|
|
.ToList(),
|
|
expectedVersions);
|
|
}
|