Added ability to get user play activity with rating filter.

This commit is contained in:
Steven Hildreth 2019-06-11 18:03:12 -05:00
parent 72953861dc
commit d453667bef
8 changed files with 64 additions and 36 deletions

View file

@ -18,6 +18,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Roadie.Library.Inspect
{
@ -244,33 +245,42 @@ namespace Roadie.Library.Inspect
pluginMetaData = pluginResult.Data;
}
// See if the MetaData from the Plugins is different from the original
var differences = AutoCompare.Comparer.Compare(originalMetaData, pluginMetaData);
if (differences.Any())
if (originalMetaData != null && pluginMetaData != null)
{
var skipDifferences = new List<string> { "AudioMetaDataWeights", "FileInfo", "Images", "TrackArtists", "ValidWeight" };
var differencesDescription = $"{ System.Environment.NewLine }";
foreach (var difference in differences)
var differences = AutoCompare.Comparer.Compare(originalMetaData, pluginMetaData);
if (differences.Any())
{
if (skipDifferences.Contains(difference.Name))
var skipDifferences = new List<string> { "AudioMetaDataWeights", "FileInfo", "Images", "TrackArtists", "ValidWeight" };
var differencesDescription = $"{ System.Environment.NewLine }";
foreach (var difference in differences)
{
continue;
if (skipDifferences.Contains(difference.Name))
{
continue;
}
differencesDescription += $"╟ || { difference.Name } : Was [{ difference.OldValue}] Now [{ difference.NewValue}]{ System.Environment.NewLine }";
}
differencesDescription += $"╟ || { difference.Name } : Was [{ difference.OldValue}] Now [{ difference.NewValue}]{ System.Environment.NewLine }";
}
Console.Write($"╟ ≡ != ID3 Tag Modified: { differencesDescription }");
Console.Write($"╟ ≡ != ID3 Tag Modified: { differencesDescription }");
if (!isReadOnly)
{
TagsHelper.WriteTags(pluginMetaData, pluginMetaData.Filename);
if (!isReadOnly)
{
TagsHelper.WriteTags(pluginMetaData, pluginMetaData.Filename);
}
else
{
Console.WriteLine("╟ ■ Read Only Mode: Not Modifying File ID3 Tags.");
}
}
else
{
Console.WriteLine("╟ ■ Read Only Mode: Not Modifying File ID3 Tags.");
Console.WriteLine($"╟ ≡ == ID3 Tag NOT Modified");
}
}
else
{
Console.WriteLine($"╟ ≡ == ID3 Tag NOT Modified");
var oBad = originalMetaData == null;
var pBad = pluginMetaData == null;
Console.WriteLine($"╟ !! MetaData comparison skipped. { (oBad ? "Pre MetaData is Invalid" : "")} { (pBad ? "Post MetaData is Invalid" : "") }");
}
if (!pluginMetaData.IsValid)
{

View file

@ -18,6 +18,14 @@ namespace Roadie.Library.Models
}
}
public string PlayedDay
{
get
{
return this.PlayedDateDateTime.HasValue ? this.PlayedDateDateTime.Value.ToString("MM/dd/yyyy") : null;
}
}
[JsonIgnore]
public DateTime? PlayedDateDateTime { get; set; }
@ -25,7 +33,7 @@ namespace Roadie.Library.Models
public DataToken Release { get; set; }
public string ReleasePlayUrl { get; set; }
public Image ReleaseThumbnail { get; set; }
public DataToken Track { get; set; }
public TrackList Track { get; set; }
public DataToken TrackArtist { get; set; }
public string TrackPlayUrl { get; set; }
public DataToken User { get; set; }

View file

@ -11,7 +11,7 @@
<PackageReference Include="AutoCompare.Core" Version="1.0.0" />
<PackageReference Include="CsvHelper" Version="12.1.2" />
<PackageReference Include="EFCore.BulkExtensions" Version="2.4.7" />
<PackageReference Include="FluentFTP" Version="24.0.0" />
<PackageReference Include="FluentFTP" Version="25.0.1" />
<PackageReference Include="Hashids.net" Version="1.2.2" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.7" />
<PackageReference Include="IdSharp.Common" Version="1.0.1" />
@ -33,7 +33,7 @@
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.5.0" />
<PackageReference Include="System.Runtime.Caching" Version="4.5.0" />
<PackageReference Include="z440.atl.core" Version="2.10.0" />
<PackageReference Include="z440.atl.core" Version="2.11.0" />
<PackageReference Include="zlib.net-mutliplatform" Version="1.0.4" />
</ItemGroup>

View file

@ -268,10 +268,7 @@ namespace Roadie.Library.MetaData.Audio
{
result = this._trackArtist.Split(AudioMetaData.ArtistSplitCharacter).First().ToTitleCase();
}
if (!string.IsNullOrEmpty(this._artist) || !string.IsNullOrEmpty(result))
{
result = !this._artist.Equals(result, StringComparison.OrdinalIgnoreCase) ? result : null;
}
result = !this._artist?.Equals(result, StringComparison.OrdinalIgnoreCase) ?? false ? result : null;
return result;
}
set

View file

@ -57,6 +57,7 @@ namespace Roadie.Api.Services
join releaseArtist in this.DbContext.Artists on r.ArtistId equals releaseArtist.Id
where (newerThan == null || usertrack.LastPlayed >= newerThan)
where ((roadieUser == null && !(u.IsPrivate ?? false)) || (roadieUser != null && (usertrack != null && usertrack.User.Id == roadieUser.Id)))
where (!request.FilterRatedOnly || (roadieUser == null && t.Rating > 0 || roadieUser != null && usertrack.Rating >0))
where (request.FilterValue.Length == 0 || (request.FilterValue.Length > 0 && (
t.Title != null && t.Title.ToLower().Contains(request.Filter.ToLower()) ||
t.AlternateNames != null && t.AlternateNames.ToLower().Contains(request.Filter.ToLower())
@ -68,11 +69,17 @@ namespace Roadie.Api.Services
Text = r.Title,
Value = r.RoadieId.ToString()
},
Track = new DataToken
{
Text = t.Title,
Value = t.RoadieId.ToString()
},
Track = TrackList.FromDataTrack(null,
t,
rm.MediaNumber,
r,
releaseArtist,
trackArtist,
this.HttpContext.BaseUrl,
this.MakeTrackThumbnailImage(t.RoadieId),
this.MakeReleaseThumbnailImage(r.RoadieId),
this.MakeArtistThumbnailImage(releaseArtist.RoadieId),
this.MakeArtistThumbnailImage(trackArtist == null ? null : (Guid?)trackArtist.RoadieId)),
User = new DataToken
{
Text = u.UserName,
@ -172,11 +179,17 @@ namespace Roadie.Api.Services
Text = track.ReleaseMedia.Release.Title,
Value = track.ReleaseMedia.Release.RoadieId.ToString()
},
Track = new DataToken
{
Text = track.Title,
Value = track.RoadieId.ToString()
},
Track = TrackList.FromDataTrack(null,
track,
track.ReleaseMedia.MediaNumber,
track.ReleaseMedia.Release,
track.ReleaseMedia.Release.Artist,
track.TrackArtist,
this.HttpContext.BaseUrl,
this.MakeTrackThumbnailImage(track.RoadieId),
this.MakeReleaseThumbnailImage(track.ReleaseMedia.Release.RoadieId),
this.MakeArtistThumbnailImage(track.ReleaseMedia.Release.Artist.RoadieId),
this.MakeArtistThumbnailImage(track.TrackArtist == null ? null : (Guid?)track.TrackArtist.RoadieId)),
User = new DataToken
{
Text = roadieUser.UserName,

View file

@ -10,7 +10,7 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.4.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.15" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.16" />
</ItemGroup>
<ItemGroup>

View file

@ -1029,14 +1029,14 @@ namespace Roadie.Api.Services
pagedRequest.Sort = null;
pagedRequest.Order = null;
pagedRequest.FilterToTrackIds = playActivityResult.Rows.Select(x => SafeParser.ToGuid(x.Track.Value)).Distinct().ToArray();
pagedRequest.FilterToTrackIds = playActivityResult.Rows.Select(x => SafeParser.ToGuid(x.Track.Track.Value)).Distinct().ToArray();
var playActivityTracksResult = await this.TrackService.List(pagedRequest, roadieUser);
var playEntries = new List<subsonic.NowPlayingEntry>();
var now = DateTime.UtcNow;
foreach (var row in playActivityResult.Rows)
{
var rowTrack = playActivityTracksResult.Rows.FirstOrDefault(x => x.Track.Value == row.Track.Value);
var rowTrack = playActivityTracksResult.Rows.FirstOrDefault(x => x.Track.Value == row.Track.Track.Value);
var playEntryTrackChild = this.SubsonicChildForTrack(rowTrack);
var playEntry = playEntryTrackChild.Adapt<subsonic.NowPlayingEntry>();
playEntry.username = row.User.Text;

View file

@ -34,7 +34,7 @@
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.RollingFileAlternate" Version="2.0.9" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.4.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.15" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.16" />
</ItemGroup>
<ItemGroup>