mirror of
https://github.com/sphildreth/roadie
synced 2025-02-16 21:18:26 +00:00
Beta v20180130.1
This commit is contained in:
parent
932f7b6987
commit
1989e67a28
1 changed files with 59 additions and 12 deletions
|
@ -217,23 +217,64 @@ namespace Roadie.Api.Services
|
||||||
if (doRandomize ?? false)
|
if (doRandomize ?? false)
|
||||||
{
|
{
|
||||||
request.Limit = roadieUser?.RandomReleaseLimit ?? 50;
|
request.Limit = roadieUser?.RandomReleaseLimit ?? 50;
|
||||||
|
var userId = roadieUser?.Id ?? -1;
|
||||||
|
|
||||||
if (!request.FilterRatedOnly && !request.FilterFavoriteOnly)
|
if (!request.FilterRatedOnly && !request.FilterFavoriteOnly)
|
||||||
{
|
{
|
||||||
var sql = "SELECT t.* " +
|
var sql = @"SELECT t.id
|
||||||
"FROM `track` t " +
|
FROM `track` t
|
||||||
"WHERE t.Hash IS NOT NULL " +
|
JOIN `releasemedia` rm on (t.releaseMediaId = rm.id)
|
||||||
"ORDER BY RAND() LIMIT {0}";
|
WHERE t.Hash IS NOT NULL
|
||||||
randomTrackIds = this.DbContext.Tracks.FromSql(sql, request.LimitValue).Select(x => x.Id).ToArray();
|
AND t.id NOT IN (SELECT ut.trackId
|
||||||
|
FROM `usertrack` ut
|
||||||
|
WHERE ut.userId = {0}
|
||||||
|
AND ut.isDisliked = 1)
|
||||||
|
AND rm.releaseId in (select distinct r.id
|
||||||
|
FROM `release` r
|
||||||
|
WHERE r.id NOT IN (SELECT ur.releaseId
|
||||||
|
FROM `userrelease` ur
|
||||||
|
WHERE ur.userId = {0}
|
||||||
|
AND ur.isDisliked = 1)
|
||||||
|
AND r.artistId IN (select DISTINCT a.id
|
||||||
|
FROM `artist` a
|
||||||
|
WHERE a.id NOT IN (select ua.artistId
|
||||||
|
FROM `userartist` ua
|
||||||
|
where ua.userId = {0}
|
||||||
|
AND ua.isDisliked = 1)
|
||||||
|
ORDER BY RAND())
|
||||||
|
ORDER BY RAND())
|
||||||
|
ORDER BY RAND()
|
||||||
|
LIMIT {1}";
|
||||||
|
randomTrackIds = this.DbContext.Tracks.FromSql(sql, userId, request.Limit).Select(x => x.Id).ToArray();
|
||||||
}
|
}
|
||||||
if (request.FilterRatedOnly && !request.FilterFavoriteOnly)
|
if (request.FilterRatedOnly && !request.FilterFavoriteOnly)
|
||||||
{
|
{
|
||||||
var sql = "SELECT t.* " +
|
var sql = @"SELECT t.id
|
||||||
"FROM `track` t " +
|
FROM `track` t
|
||||||
"WHERE t.Hash IS NOT NULL " +
|
JOIN `releasemedia` rm on (t.releaseMediaId = rm.id)
|
||||||
"AND t.rating > 0 " +
|
WHERE t.Hash IS NOT NULL
|
||||||
"ORDER BY RAND() LIMIT {0}";
|
AND t.rating > 0
|
||||||
randomTrackIds = this.DbContext.Tracks.FromSql(sql, request.LimitValue).Select(x => x.Id).ToArray();
|
AND t.id NOT IN (SELECT ut.trackId
|
||||||
|
FROM `usertrack` ut
|
||||||
|
WHERE ut.userId = {0}
|
||||||
|
AND ut.isDisliked = 1)
|
||||||
|
AND rm.releaseId in (select distinct r.id
|
||||||
|
FROM `release` r
|
||||||
|
WHERE r.id NOT IN (SELECT ur.releaseId
|
||||||
|
FROM `userrelease` ur
|
||||||
|
WHERE ur.userId = {0}
|
||||||
|
AND ur.isDisliked = 1)
|
||||||
|
AND r.artistId IN (select DISTINCT a.id
|
||||||
|
FROM `artist` a
|
||||||
|
WHERE a.id NOT IN (select ua.artistId
|
||||||
|
FROM `userartist` ua
|
||||||
|
where ua.userId = {0}
|
||||||
|
AND ua.isDisliked = 1)
|
||||||
|
ORDER BY RAND())
|
||||||
|
ORDER BY RAND())
|
||||||
|
ORDER BY RAND()
|
||||||
|
LIMIT {1}";
|
||||||
|
randomTrackIds = this.DbContext.Tracks.FromSql(sql, userId, request.LimitValue).Select(x => x.Id).ToArray();
|
||||||
}
|
}
|
||||||
if (request.FilterFavoriteOnly)
|
if (request.FilterFavoriteOnly)
|
||||||
{
|
{
|
||||||
|
@ -274,7 +315,11 @@ namespace Roadie.Api.Services
|
||||||
where (releaseId == null || (releaseId != null && r.RoadieId == releaseId))
|
where (releaseId == null || (releaseId != null && r.RoadieId == releaseId))
|
||||||
where (filterToTrackIds == null || filterToTrackIds.Contains(t.RoadieId))
|
where (filterToTrackIds == null || filterToTrackIds.Contains(t.RoadieId))
|
||||||
where (request.FilterMinimumRating == null || t.Rating >= request.FilterMinimumRating.Value)
|
where (request.FilterMinimumRating == null || t.Rating >= request.FilterMinimumRating.Value)
|
||||||
where (request.FilterValue == "" || (t.Title.Contains(request.FilterValue) || t.AlternateNames.Contains(request.FilterValue) || t.AlternateNames.Contains(normalizedFilterValue)))
|
where (request.FilterValue == "" ||
|
||||||
|
(t.Title.Contains(request.FilterValue) ||
|
||||||
|
t.AlternateNames.Contains(request.FilterValue) ||
|
||||||
|
t.AlternateNames.Contains(normalizedFilterValue)) ||
|
||||||
|
t.PartTitles.Contains(request.FilterValue))
|
||||||
where (!request.FilterFavoriteOnly || favoriteTrackIds.Contains(t.Id))
|
where (!request.FilterFavoriteOnly || favoriteTrackIds.Contains(t.Id))
|
||||||
where (request.FilterToPlaylistId == null || playlistTrackIds.Contains(t.Id))
|
where (request.FilterToPlaylistId == null || playlistTrackIds.Contains(t.Id))
|
||||||
where (!request.FilterTopPlayedOnly || topTrackids.Contains(t.Id))
|
where (!request.FilterTopPlayedOnly || topTrackids.Contains(t.Id))
|
||||||
|
@ -294,6 +339,7 @@ namespace Roadie.Api.Services
|
||||||
t.Duration,
|
t.Duration,
|
||||||
t.FileSize,
|
t.FileSize,
|
||||||
t.PlayedCount,
|
t.PlayedCount,
|
||||||
|
t.PartTitles,
|
||||||
t.Rating,
|
t.Rating,
|
||||||
t.Tags,
|
t.Tags,
|
||||||
t.TrackNumber,
|
t.TrackNumber,
|
||||||
|
@ -395,6 +441,7 @@ namespace Roadie.Api.Services
|
||||||
LastUpdated = x.ti.LastUpdated,
|
LastUpdated = x.ti.LastUpdated,
|
||||||
MediaNumber = x.rmi.MediaNumber,
|
MediaNumber = x.rmi.MediaNumber,
|
||||||
PlayedCount = x.ti.PlayedCount,
|
PlayedCount = x.ti.PlayedCount,
|
||||||
|
PartTitles = x.ti.PartTitles,
|
||||||
Rating = x.ti.Rating,
|
Rating = x.ti.Rating,
|
||||||
Release = x.rl,
|
Release = x.rl,
|
||||||
ReleaseDate = x.rl.ReleaseDateDateTime,
|
ReleaseDate = x.rl.ReleaseDateDateTime,
|
||||||
|
|
Loading…
Add table
Reference in a new issue