mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 05:11:10 +00:00
Refactors the track slice across the stack
This commit is contained in:
1 parent
d4cc3c1f8d
commit
b398f26bfe
25 files changed
+2927
-432
No files matched your search
Generated
+2609
File diff suppressed because it is too large.
Load diff
+37
@@ -0,0 +1,37 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MakesTrackPathUniquePerLibrary : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Tracks_LibraryId_Path",
|
||||
table: "Tracks");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Tracks_LibraryId_Path",
|
||||
table: "Tracks",
|
||||
columns: new[] { "LibraryId", "Path" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Tracks_LibraryId_Path",
|
||||
table: "Tracks");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Tracks_LibraryId_Path",
|
||||
table: "Tracks",
|
||||
columns: new[] { "LibraryId", "Path" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,28 +194,12 @@ internal sealed class TrackRepository : ITrackRepository
|
||||
.Include(track => track.Genres)
|
||||
.Include(track => track.Moods)
|
||||
.Include(track => track.Isrcs)
|
||||
.Include(track => track.Contributors);
|
||||
.Include(track => track.Contributors)
|
||||
.AsSplitQuery();
|
||||
}
|
||||
return await query.FirstOrDefaultAsync(track => track.Id == id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the track identified by <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The Id of the track to delete.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Deleted>> DeleteByIdAsync(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
TrackEntity? track = await _luminaDbContext.Tracks
|
||||
.FirstOrDefaultAsync(repositoryTrack => repositoryTrack.Id == id, cancellationToken).ConfigureAwait(false);
|
||||
if (track is null)
|
||||
return Errors.Music.TrackNotFound;
|
||||
|
||||
_luminaDbContext.Tracks.Remove(track);
|
||||
return Result.Deleted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the tracks of the album identified by <paramref name="albumId"/>.
|
||||
/// </summary>
|
||||
@@ -231,6 +215,7 @@ internal sealed class TrackRepository : ITrackRepository
|
||||
.Include(track => track.Moods)
|
||||
.Include(track => track.Isrcs)
|
||||
.Include(track => track.Contributors)
|
||||
.AsSplitQuery()
|
||||
.Where(track => track.AlbumId == albumId)
|
||||
.OrderBy(track => track.DiscNumber)
|
||||
.ThenBy(track => track.TrackNumber)
|
||||
|
||||
Reference in new issue
Block a user