mirror of
https://github.com/sphildreth/roadie
synced 2024-11-10 06:44:12 +00:00
Codemaide Cleanup.
This commit is contained in:
parent
06b0bfffe5
commit
0409f01039
18 changed files with 69 additions and 109 deletions
|
@ -6,9 +6,6 @@ using Microsoft.Extensions.Logging;
|
|||
using Roadie.Api.Services;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Identity;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Api.Controllers
|
||||
{
|
||||
|
@ -26,7 +23,5 @@ namespace Roadie.Api.Controllers
|
|||
this._logger = logger.CreateLogger("RoadieApi.Controllers.SubsonicController");
|
||||
this.SubsonicService = subsonicService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -198,7 +198,7 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
if (includes.Contains("collections"))
|
||||
{
|
||||
var r = await this.CollectionService.List(roadieUser: null,
|
||||
var r = await this.CollectionService.List(roadieUser: null,
|
||||
request: new PagedRequest(), artistId: artist.RoadieId);
|
||||
if (r.IsSuccess)
|
||||
{
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Encoding;
|
||||
using Roadie.Library.Enums;
|
||||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Releases;
|
||||
using Roadie.Library.Models.Statistics;
|
||||
using Roadie.Library.Models.Users;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
|
@ -46,7 +40,6 @@ namespace Roadie.Api.Services
|
|||
request.Sort = request.Sort.Replace("bookmarkType", "bookmarkTypeValue");
|
||||
request.Sort = request.Sort.Replace("createdDate", "createdDateTime");
|
||||
request.Sort = request.Sort.Replace("lastUpdated", "lastUpdatedDateTime");
|
||||
|
||||
}
|
||||
|
||||
var result = (from b in this.DbContext.Bookmarks
|
||||
|
@ -61,27 +54,26 @@ namespace Roadie.Api.Services
|
|||
Type = b.BookmarkType,
|
||||
BookmarkTargetId = b.BookmarkTargetId
|
||||
});
|
||||
|
||||
|
||||
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "CreatedDate", "DESC" } }) : request.OrderValue(null);
|
||||
var rowCount = result.Count();
|
||||
BookmarkList[] rows = rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||
|
||||
var datas = (from b in rows
|
||||
join a in this.DbContext.Artists on b.BookmarkTargetId equals a.Id into aa
|
||||
from a in aa.DefaultIfEmpty()
|
||||
join r in this.DbContext.Releases on b.BookmarkTargetId equals r.Id into rr
|
||||
from r in rr.DefaultIfEmpty()
|
||||
join t in this.DbContext.Tracks on b.BookmarkTargetId equals t.Id into tt
|
||||
from t in rr.DefaultIfEmpty()
|
||||
join p in this.DbContext.Playlists on b.BookmarkTargetId equals p.Id into pp
|
||||
from p in pp.DefaultIfEmpty()
|
||||
join c in this.DbContext.Collections on b.BookmarkTargetId equals c.Id into cc
|
||||
from c in cc.DefaultIfEmpty()
|
||||
join l in this.DbContext.Labels on b.BookmarkTargetId equals l.Id into ll
|
||||
from l in ll.DefaultIfEmpty()
|
||||
select new
|
||||
{ b,a,r,t,p,c,l});
|
||||
join a in this.DbContext.Artists on b.BookmarkTargetId equals a.Id into aa
|
||||
from a in aa.DefaultIfEmpty()
|
||||
join r in this.DbContext.Releases on b.BookmarkTargetId equals r.Id into rr
|
||||
from r in rr.DefaultIfEmpty()
|
||||
join t in this.DbContext.Tracks on b.BookmarkTargetId equals t.Id into tt
|
||||
from t in rr.DefaultIfEmpty()
|
||||
join p in this.DbContext.Playlists on b.BookmarkTargetId equals p.Id into pp
|
||||
from p in pp.DefaultIfEmpty()
|
||||
join c in this.DbContext.Collections on b.BookmarkTargetId equals c.Id into cc
|
||||
from c in cc.DefaultIfEmpty()
|
||||
join l in this.DbContext.Labels on b.BookmarkTargetId equals l.Id into ll
|
||||
from l in ll.DefaultIfEmpty()
|
||||
select new
|
||||
{ b, a, r, t, p, c, l });
|
||||
|
||||
foreach (var row in rows)
|
||||
{
|
||||
|
@ -96,6 +88,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
row.Thumbnail = this.MakeArtistThumbnailImage(d.a.RoadieId);
|
||||
break;
|
||||
|
||||
case BookmarkType.Release:
|
||||
row.Bookmark = new DataToken
|
||||
{
|
||||
|
@ -104,6 +97,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
row.Thumbnail = this.MakeReleaseThumbnailImage(d.r.RoadieId);
|
||||
break;
|
||||
|
||||
case BookmarkType.Track:
|
||||
row.Bookmark = new DataToken
|
||||
{
|
||||
|
@ -112,6 +106,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
row.Thumbnail = this.MakeTrackThumbnailImage(d.t.RoadieId);
|
||||
break;
|
||||
|
||||
case BookmarkType.Playlist:
|
||||
row.Bookmark = new DataToken
|
||||
{
|
||||
|
@ -120,6 +115,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
row.Thumbnail = this.MakePlaylistThumbnailImage(d.p.RoadieId);
|
||||
break;
|
||||
|
||||
case BookmarkType.Collection:
|
||||
row.Bookmark = new DataToken
|
||||
{
|
||||
|
@ -128,6 +124,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
row.Thumbnail = this.MakeCollectionThumbnailImage(d.c.RoadieId);
|
||||
break;
|
||||
|
||||
case BookmarkType.Label:
|
||||
row.Bookmark = new DataToken
|
||||
{
|
||||
|
@ -140,7 +137,6 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
sw.Stop();
|
||||
|
||||
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<BookmarkList>
|
||||
{
|
||||
|
@ -152,4 +148,4 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ namespace Roadie.Api.Services
|
|||
LastUpdated = c.LastUpdated,
|
||||
Thumbnail = MakeCollectionThumbnailImage(c.RoadieId)
|
||||
});
|
||||
if(artistId.HasValue || releaseId.HasValue)
|
||||
if (artistId.HasValue || releaseId.HasValue)
|
||||
{
|
||||
result = (from re in result
|
||||
join cr in this.DbContext.CollectionReleases on re.DatabaseId equals cr.CollectionId into crs
|
||||
|
@ -70,7 +70,7 @@ namespace Roadie.Api.Services
|
|||
join a in this.DbContext.Artists on r.ArtistId equals a.Id into aas
|
||||
from a in aas.DefaultIfEmpty()
|
||||
where (releaseId == null || r.RoadieId == releaseId)
|
||||
where (artistId == null || a.RoadieId == artistId)
|
||||
where (artistId == null || a.RoadieId == artistId)
|
||||
select re);
|
||||
}
|
||||
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "Collection.Text", "ASC" } }) : request.OrderValue(null);
|
||||
|
|
|
@ -68,4 +68,4 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using System.Threading.Tasks;
|
||||
using Roadie.Library.Enums;
|
||||
using Roadie.Library.Enums;
|
||||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Users;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
public interface ICollectionService
|
||||
{
|
||||
|
||||
Task<PagedResult<CollectionList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, Guid? releaseId = null, Guid? artistId = null);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Users;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
|
|
|
@ -12,12 +12,12 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
Task<FileOperationResult<Library.Models.Image>> ArtistThumbnail(Guid id, int? width, int? height, EntityTagHeaderValue etag = null);
|
||||
|
||||
Task<FileOperationResult<Library.Models.Image>> ById(Guid id, int? width, int? height, EntityTagHeaderValue etag = null);
|
||||
|
||||
Task<FileOperationResult<Library.Models.Image>> CollectionThumbnail(Guid id, int? width, int? height, EntityTagHeaderValue etag = null);
|
||||
|
||||
Task<OperationResult<bool>> Delete(User user, Guid id);
|
||||
|
||||
Task<FileOperationResult<Library.Models.Image>> ById(Guid id, int? width, int? height, EntityTagHeaderValue etag = null);
|
||||
|
||||
Task<OperationResult<IEnumerable<ImageSearchResult>>> ImageProvidersSearch(string query);
|
||||
|
||||
Task<FileOperationResult<Library.Models.Image>> LabelThumbnail(Guid id, int? width, int? height, EntityTagHeaderValue etag = null);
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
|
@ -12,4 +9,4 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
Task<PagedResult<LabelList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Users;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
public interface ISubsonicService
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using System.Threading.Tasks;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Users;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
|
|
|
@ -51,6 +51,20 @@ namespace Roadie.Api.Services
|
|||
etag: etag);
|
||||
}
|
||||
|
||||
public async Task<FileOperationResult<Image>> ById(Guid id, int? width, int? height, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
return await this.GetImageFileOperation(type: "ImageById",
|
||||
regionUrn: data.Image.CacheRegionUrn(id),
|
||||
id: id,
|
||||
width: width,
|
||||
height: height,
|
||||
action: async () =>
|
||||
{
|
||||
return await this.ImageByIdAction(id, etag);
|
||||
},
|
||||
etag: etag);
|
||||
}
|
||||
|
||||
public async Task<FileOperationResult<Image>> CollectionThumbnail(Guid id, int? width, int? height, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
return await this.GetImageFileOperation(type: "CollectionThumbnail",
|
||||
|
@ -97,20 +111,6 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<FileOperationResult<Image>> ById(Guid id, int? width, int? height, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
return await this.GetImageFileOperation(type: "ImageById",
|
||||
regionUrn: data.Image.CacheRegionUrn(id),
|
||||
id: id,
|
||||
width: width,
|
||||
height: height,
|
||||
action: async () =>
|
||||
{
|
||||
return await this.ImageByIdAction(id, etag);
|
||||
},
|
||||
etag: etag);
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<ImageSearchResult>>> ImageProvidersSearch(string query)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Encoding;
|
||||
using Roadie.Library.Enums;
|
||||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Releases;
|
||||
using Roadie.Library.Models.Statistics;
|
||||
using Roadie.Library.Models.Users;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
|
@ -104,4 +97,4 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -105,4 +105,4 @@ namespace Roadie.Api.Services
|
|||
return new Library.Models.Pagination.PagedResult<PlayActivityList>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +1,8 @@
|
|||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Encoding;
|
||||
using Roadie.Library.Enums;
|
||||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.Models;
|
||||
using Roadie.Library.Models.Pagination;
|
||||
using Roadie.Library.Models.Releases;
|
||||
using Roadie.Library.Models.Statistics;
|
||||
using Roadie.Library.Models.Users;
|
||||
using Roadie.Library.Models.ThirdPartyApi.Subsonic;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Threading.Tasks;
|
||||
using data = Roadie.Library.Data;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
|
@ -41,7 +24,7 @@ namespace Roadie.Api.Services
|
|||
ICollectionService collectionService,
|
||||
IPlaylistService playlistService)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger, httpContext)
|
||||
{
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -80,12 +80,12 @@ namespace Roadie.Api.Services
|
|||
var userTracks = this.DbContext.UserTracks.Include(x => x.Track).Where(x => x.UserId == row.DatabaseId).ToArray();
|
||||
|
||||
var mostPlayedArtist = (from a in this.DbContext.Artists
|
||||
join r in this.DbContext.Releases on a.Id equals r.ArtistId
|
||||
join rm in this.DbContext.ReleaseMedias on r.Id equals rm.ReleaseId
|
||||
join t in this.DbContext.Tracks on rm.Id equals t.ReleaseMediaId
|
||||
join ut in this.DbContext.UserTracks on t.Id equals ut.TrackId
|
||||
where ut.UserId == row.DatabaseId
|
||||
select new { a, ut.PlayedCount })
|
||||
join r in this.DbContext.Releases on a.Id equals r.ArtistId
|
||||
join rm in this.DbContext.ReleaseMedias on r.Id equals rm.ReleaseId
|
||||
join t in this.DbContext.Tracks on rm.Id equals t.ReleaseMediaId
|
||||
join ut in this.DbContext.UserTracks on t.Id equals ut.TrackId
|
||||
where ut.UserId == row.DatabaseId
|
||||
select new { a, ut.PlayedCount })
|
||||
.GroupBy(a => a.a)
|
||||
.Select(x => new DataToken
|
||||
{
|
||||
|
@ -103,10 +103,12 @@ namespace Roadie.Api.Services
|
|||
where ut.UserId == row.DatabaseId
|
||||
select new { r, ut.PlayedCount })
|
||||
.GroupBy(r => r.r)
|
||||
.Select(x => new DataToken {
|
||||
.Select(x => new DataToken
|
||||
{
|
||||
Text = x.Key.Title,
|
||||
Value = x.Key.RoadieId.ToString(),
|
||||
Data = x.Sum(t => t.PlayedCount) })
|
||||
Data = x.Sum(t => t.PlayedCount)
|
||||
})
|
||||
.OrderByDescending(x => x.Data)
|
||||
.FirstOrDefault();
|
||||
|
||||
|
|
Loading…
Reference in a new issue