···44444545 const cachedTracks = output.data.tracks.collection;
46464747- // TODO: Is there a better time to do this?
4848- // Goal = figure out servers/buckets/context used,
4949- // which are then used in the following `list` action.
5047 await input.sendAction("contextualize", cachedTracks, {
5148 timeoutDuration: 60000 * 5,
5249 });
+18-3
src/pages/orchestrator/queue-tracks/_applet.astro
···11<script>
22- import type { ManagedOutput } from "@applets/core/types.d.ts";
22+ import type { GroupConsult, ManagedOutput, Track } from "@applets/core/types.d.ts";
33 import { applet, makeConnect, register, wait } from "@scripts/applet/common";
4455 ////////////////////////////////////////////
66 // SETUP
77 ////////////////////////////////////////////
88 import type * as QueueEngine from "@applets/engine/queue/types.d.ts";
99+ import { groupTracksPerScheme } from "@scripts/common";
9101011 // Register applet
1112 const context = register();
···13141415 // Applet connections
1516 const configurator = {
1717+ input: await applet("/configurator/input"),
1618 output: await applet<ManagedOutput>("/configurator/output"),
1719 };
1820···2830 // Add tracks to the queue once the tracks have been loaded;
2931 // and every time the collection changes.
30323131- wait(configurator.output, (d) => d?.tracks.state === "loaded").then(() => {
3333+ wait(configurator.output, (d) => d?.tracks.state === "loaded").then(async () => {
3234 connect(
3335 configurator.output,
3436 (data) => data.tracks.cacheId,
3535- () => engine.queue.sendAction("fill", configurator.output.data.tracks.collection),
3737+ async () => {
3838+ const groups = await configurator.input.sendAction<GroupConsult>(
3939+ "groupConsult",
4040+ configurator.output.data.tracks.collection,
4141+ { timeoutDuration: 60000 * 5 },
4242+ );
4343+4444+ const tracks = Object.values(groups).reduce((acc: Track[], value) => {
4545+ if (value.available === false) return acc;
4646+ return [...acc, ...value.tracks];
4747+ }, []);
4848+4949+ engine.queue.sendAction("fill", tracks);
5050+ },
3651 );
3752 });
3853</script>