feat: recommend server-generated mixes from Musify and YouTube Music

Mixes are their own concept, not playlists: they live in their own
Mixes/MixItems tables, cannot be edited and never show up among the
user's playlists. Each item is either a Musify track or a YouTube Music
reference, so YouTube songs stream directly instead of being downloaded.

A daily Hangfire job seeds the mixes from the listening history: one
discovery mix, one daily mix and one per top artist.

The per-user YouTube filler query was already in the working tree and
rides along here because it shares files with this change.
This commit is contained in:
2026-07-21 18:13:07 +02:00
parent 2cb51f540e
commit 90e842d084
36 changed files with 2667 additions and 13 deletions
@@ -0,0 +1,97 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Musify.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddMixes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Mixes",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<long>(type: "bigint", nullable: false),
Title = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
Subtitle = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
GeneratedOn = table.Column<DateOnly>(type: "date", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Mixes", x => x.Id);
table.ForeignKey(
name: "FK_Mixes_User_UserId",
column: x => x.UserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MixItems",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
MixId = table.Column<Guid>(type: "uuid", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
Source = table.Column<int>(type: "integer", nullable: false),
TrackId = table.Column<Guid>(type: "uuid", nullable: true),
VideoId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
Title = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: true),
Artist = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: true),
ThumbnailUrl = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
DurationSeconds = table.Column<int>(type: "integer", nullable: false),
IsExplicit = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MixItems", x => x.Id);
table.ForeignKey(
name: "FK_MixItems_Mixes_MixId",
column: x => x.MixId,
principalTable: "Mixes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_MixItems_Tracks_TrackId",
column: x => x.TrackId,
principalTable: "Tracks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Mixes_UserId_Position",
table: "Mixes",
columns: new[] { "UserId", "Position" });
migrationBuilder.CreateIndex(
name: "IX_MixItems_MixId_Position",
table: "MixItems",
columns: new[] { "MixId", "Position" });
migrationBuilder.CreateIndex(
name: "IX_MixItems_TrackId",
table: "MixItems",
column: "TrackId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MixItems");
migrationBuilder.DropTable(
name: "Mixes");
}
}
}