injecting artist scrobble count
removing all now playings from pages
This commit is contained in:
parent
abf22f6cf9
commit
d6e720ed72
@ -97,11 +97,11 @@ namespace Selector
|
||||
scrobbles = page1.Scrobbles;
|
||||
}
|
||||
|
||||
IdentifyDuplicates(scrobbles);
|
||||
|
||||
logger.LogDebug("Ordering and filtering pulled scrobbles");
|
||||
|
||||
scrobbles = RemoveNowPlaying(scrobbles);
|
||||
scrobbles = scrobbles.Where(s => !(s.IsNowPlaying is bool playing && playing));
|
||||
|
||||
IdentifyDuplicates(scrobbles);
|
||||
|
||||
var nativeScrobbles = scrobbles
|
||||
.DistinctBy(s => new { s.TimePlayed?.UtcDateTime, s.Name, s.ArtistName })
|
||||
|
@ -28,11 +28,13 @@ namespace Selector.Web.Hubs
|
||||
private readonly AudioFeaturePuller AudioFeaturePuller;
|
||||
private readonly PlayCountPuller PlayCountPuller;
|
||||
private readonly ApplicationDbContext Db;
|
||||
private readonly IScrobbleRepository ScrobbleRepository;
|
||||
|
||||
public NowPlayingHub(
|
||||
IDatabaseAsync cache,
|
||||
AudioFeaturePuller featurePuller,
|
||||
ApplicationDbContext db,
|
||||
IScrobbleRepository scrobbleRepository,
|
||||
PlayCountPuller playCountPuller = null
|
||||
)
|
||||
{
|
||||
@ -40,6 +42,7 @@ namespace Selector.Web.Hubs
|
||||
AudioFeaturePuller = featurePuller;
|
||||
PlayCountPuller = playCountPuller;
|
||||
Db = db;
|
||||
ScrobbleRepository = scrobbleRepository;
|
||||
}
|
||||
|
||||
public async Task OnConnected()
|
||||
@ -93,6 +96,11 @@ namespace Selector.Web.Hubs
|
||||
{
|
||||
var playCount = await PlayCountPuller.Get(user.LastFmUsername, track, artist, album, albumArtist);
|
||||
|
||||
if (user.ScrobbleSavingEnabled())
|
||||
{
|
||||
playCount.Artist = ScrobbleRepository.GetAll(userId: user.Id, artistName: artist).Count();
|
||||
}
|
||||
|
||||
if (playCount is not null)
|
||||
{
|
||||
await Clients.Caller.OnNewPlayCount(playCount);
|
||||
|
@ -54,6 +54,7 @@ namespace Selector.Web
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
options.UseNpgsql(Configuration.GetConnectionString("Default"))
|
||||
);
|
||||
services.AddTransient<IScrobbleRepository, ScrobbleRepository>();
|
||||
|
||||
services.AddIdentity<ApplicationUser, IdentityRole>()
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>()
|
||||
|
@ -17,7 +17,7 @@ namespace Selector
|
||||
/// </summary>
|
||||
/// <param name="watcher">New watcher</param>
|
||||
/// <param name="consumers">Consumers to subscribe to new watcher</param>
|
||||
public IWatcherContext Add(IWatcher watcher, List<IConsumer> consumers);
|
||||
public IWatcherContext Add(IWatcher watcher, IEnumerable<IConsumer> consumers);
|
||||
|
||||
/// <summary>
|
||||
/// Start watcher collection
|
||||
|
@ -43,7 +43,7 @@ namespace Selector
|
||||
return Add(watcher, default);
|
||||
}
|
||||
|
||||
public IWatcherContext Add(IWatcher watcher, List<IConsumer> consumers)
|
||||
public IWatcherContext Add(IWatcher watcher, IEnumerable<IConsumer> consumers)
|
||||
{
|
||||
var context = WatcherContext.From(watcher, consumers);
|
||||
if (IsRunning) context.Start();
|
||||
|
@ -24,10 +24,10 @@ namespace Selector
|
||||
Watcher = watcher;
|
||||
}
|
||||
|
||||
public WatcherContext(IWatcher watcher, List<IConsumer> consumers)
|
||||
public WatcherContext(IWatcher watcher, IEnumerable<IConsumer> consumers)
|
||||
{
|
||||
Watcher = watcher;
|
||||
Consumers = consumers ?? new();
|
||||
Consumers = consumers.ToList() ?? new();
|
||||
}
|
||||
|
||||
public static WatcherContext From(IWatcher watcher)
|
||||
@ -35,7 +35,7 @@ namespace Selector
|
||||
return new(watcher);
|
||||
}
|
||||
|
||||
public static WatcherContext From(IWatcher watcher, List<IConsumer> consumers)
|
||||
public static WatcherContext From(IWatcher watcher, IEnumerable<IConsumer> consumers)
|
||||
{
|
||||
return new(watcher, consumers);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user