using metarepo

This commit is contained in:
Andy Pack 2022-10-08 17:07:50 +01:00
parent 75415b4db4
commit 26b4c3fa64
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
4 changed files with 20 additions and 24 deletions

View File

@ -121,8 +121,8 @@ namespace Selector.CLI.Extensions
services.AddTransient<IScrobbleRepository, ScrobbleRepository>()
.AddTransient<ISpotifyListenRepository, SpotifyListenRepository>();
//services.AddTransient<IListenRepository, MetaListenRepository>();
services.AddTransient<IListenRepository, SpotifyListenRepository>();
services.AddTransient<IListenRepository, MetaListenRepository>();
//services.AddTransient<IListenRepository, SpotifyListenRepository>();
services.AddTransient<IScrobbleMappingRepository, ScrobbleMappingRepository>();

View File

@ -1,8 +1,6 @@
using System;
using System.Text.Json;
using Selector.Model;
using System.Text.Json;
using Microsoft.Extensions.Logging;
using System.Diagnostics.Metrics;
using Selector.Model;
namespace Selector.Data;
@ -60,14 +58,16 @@ public class HistoryPersister
{
if (Config.InitialClear)
{
Db.SpotifyListen.RemoveRange(Db.SpotifyListen.Where(x => x.User.UserName == Config.Username));
var latestTime = input.OrderBy(x => x.ts).Last().ts;
var time = DateTime.Parse(latestTime).ToUniversalTime();
Db.SpotifyListen.RemoveRange(Db.SpotifyListen.Where(x => x.User.UserName == Config.Username && x.Timestamp <= time));
}
var user = Db.Users.Single(u => u.UserName == Config.Username);
var counter = 0;
var filtered = input.Where(x => x.ms_played > 20000)
var filtered = input.Where(x => x.ms_played > 30000)
.DistinctBy(x => (x.offline_timestamp, x.ts, x.spotify_track_uri))
.ToArray();

View File

@ -4,11 +4,6 @@ using System.Linq;
namespace Selector.Model;
public enum PreferenceMode
{
Greedy, LastFm, Spotify
}
public class MetaListenRepository: IListenRepository
{
private readonly IScrobbleRepository scrobbleRepository;
@ -27,10 +22,13 @@ public class MetaListenRepository: IListenRepository
string albumName = null,
string artistName = null,
DateTime? from = null,
DateTime? to = null)
{
throw new NotImplementedException();
}
DateTime? to = null) => GetAll(userId: userId,
username: username,
trackName: trackName,
albumName: albumName,
artistName: artistName,
from: from,
to:to).Count();
public IEnumerable<IListen> GetAll(
string includes = null,
@ -62,14 +60,12 @@ public class MetaListenRepository: IListenRepository
albumName: albumName,
artistName: artistName,
from: from,
to: to)
to: scrobbles.FirstOrDefault()?.Timestamp)
.OrderBy(x => x.Timestamp)
.ToArray();
var scrobbleIter = scrobbles.GetEnumerator();
var spotIter = spotListens.GetEnumerator();
return scrobbles;
return spotListens.Concat(scrobbles);
}
}

View File

@ -67,8 +67,8 @@ namespace Selector.Web
services.AddTransient<IScrobbleRepository, ScrobbleRepository>()
.AddTransient<ISpotifyListenRepository, SpotifyListenRepository>();
//services.AddTransient<IListenRepository, MetaListenRepository>();
services.AddTransient<IListenRepository, SpotifyListenRepository>();
services.AddTransient<IListenRepository, MetaListenRepository>();
//services.AddTransient<IListenRepository, SpotifyListenRepository>();
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()