mirror of
https://github.com/sphildreth/roadie
synced 2024-11-10 06:44:12 +00:00
Several bug fixes.
This commit is contained in:
parent
cadf5872cc
commit
3c86801745
13 changed files with 51 additions and 92 deletions
|
@ -702,31 +702,16 @@ namespace Roadie.Library.Engines
|
|||
}
|
||||
try
|
||||
{
|
||||
var getParams = new List<object>();
|
||||
var searchName = name.NormalizeName().ToLower();
|
||||
var searchSortName = !string.IsNullOrEmpty(sortName) ? sortName.NormalizeName().ToLower() : searchName;
|
||||
var searchName = name.NormalizeName();
|
||||
var specialSearchName = name.ToAlphanumericName();
|
||||
getParams.Add(new MySqlParameter("@isName", searchName));
|
||||
getParams.Add(new MySqlParameter("@isSortName", searchSortName));
|
||||
getParams.Add(new MySqlParameter("@startAlt", string.Format("{0}|%", searchName)));
|
||||
getParams.Add(new MySqlParameter("@inAlt", string.Format("%|{0}|%", searchName)));
|
||||
getParams.Add(new MySqlParameter("@endAlt", string.Format("%|{0}", searchName)));
|
||||
getParams.Add(new MySqlParameter("@sstartAlt", string.Format("{0}|%", specialSearchName)));
|
||||
getParams.Add(new MySqlParameter("@sinAlt", string.Format("%|{0}|%", specialSearchName)));
|
||||
getParams.Add(new MySqlParameter("@sendAlt", string.Format("%|{0}", specialSearchName)));
|
||||
return this.DbContext.Artists.FromSql(@"SELECT *
|
||||
FROM `artist`
|
||||
WHERE LCASE(name) = @isName
|
||||
OR LCASE(sortName) = @isName
|
||||
OR LCASE(sortName) = @isSortName
|
||||
OR LCASE(alternatenames) = @isName
|
||||
OR alternatenames like @startAlt
|
||||
OR alternatenames like @sstartAlt
|
||||
OR alternatenames like @inAlt
|
||||
OR alternatenames like @sinAlt
|
||||
OR (alternatenames like @endAlt
|
||||
OR alternatenames like @sendAlt)
|
||||
LIMIT 1", getParams.ToArray()).FirstOrDefault();
|
||||
return (from a in this.DbContext.Artists
|
||||
where (a.Name.Contains(searchName) ||
|
||||
a.SortName.Contains(searchName) ||
|
||||
a.AlternateNames.Contains(searchName) ||
|
||||
a.AlternateNames.Contains(specialSearchName))
|
||||
select a
|
||||
).FirstOrDefault();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -64,14 +64,14 @@ namespace Roadie.Library.Engines
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<OperationResult<Label>> GetByName(string LabelName, bool doFindIfNotInDatabase = false)
|
||||
public async Task<OperationResult<Label>> GetByName(string labelName, bool doFindIfNotInDatabase = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
var cacheRegion = (new Label { Name = LabelName }).CacheRegion;
|
||||
var cacheKey = string.Format("urn:Label_by_name:{0}", LabelName);
|
||||
var cacheRegion = (new Label { Name = labelName }).CacheRegion;
|
||||
var cacheKey = string.Format("urn:Label_by_name:{0}", labelName);
|
||||
var resultInCache = this.CacheManager.Get<Label>(cacheKey, cacheRegion);
|
||||
if (resultInCache != null)
|
||||
{
|
||||
|
@ -83,31 +83,25 @@ namespace Roadie.Library.Engines
|
|||
Data = resultInCache
|
||||
};
|
||||
}
|
||||
var getParams = new List<object>();
|
||||
var searchName = LabelName.NormalizeName().ToLower();
|
||||
getParams.Add(new MySqlParameter("@isName", searchName));
|
||||
getParams.Add(new MySqlParameter("@startAlt", string.Format("{0}|%", searchName)));
|
||||
getParams.Add(new MySqlParameter("@inAlt", string.Format("%|{0}|%", searchName)));
|
||||
getParams.Add(new MySqlParameter("@endAlt", string.Format("%|{0}", searchName)));
|
||||
var Label = this.DbContext.Labels.FromSql(@"SELECT *
|
||||
FROM `label`
|
||||
WHERE LCASE(name) = @isName
|
||||
OR LCASE(sortName) = @isName
|
||||
OR LCASE(alternatenames) = @isName
|
||||
OR alternatenames like @startAlt
|
||||
OR alternatenames like @inAlt
|
||||
OR alternatenames like @endAlt
|
||||
LIMIT 1", getParams.ToArray()).FirstOrDefault();
|
||||
var searchName = labelName.NormalizeName();
|
||||
var specialSearchName = labelName.ToAlphanumericName();
|
||||
var label = (from l in this.DbContext.Labels
|
||||
where (l.Name.Contains(searchName) ||
|
||||
l.SortName.Contains(searchName) ||
|
||||
l.AlternateNames.Contains(searchName) ||
|
||||
l.AlternateNames.Contains(specialSearchName))
|
||||
select l
|
||||
).FirstOrDefault();
|
||||
sw.Stop();
|
||||
if (Label == null || !Label.IsValid)
|
||||
if (label == null || !label.IsValid)
|
||||
{
|
||||
this.Logger.LogInformation("LabelFactory: Label Not Found By Name [{0}]", LabelName);
|
||||
this.Logger.LogInformation("LabelFactory: Label Not Found By Name [{0}]", labelName);
|
||||
if (doFindIfNotInDatabase)
|
||||
{
|
||||
OperationResult<Label> LabelSearch = null;
|
||||
try
|
||||
{
|
||||
LabelSearch = await this.PerformMetaDataProvidersLabelSearch(LabelName);
|
||||
LabelSearch = await this.PerformMetaDataProvidersLabelSearch(labelName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -115,8 +109,8 @@ namespace Roadie.Library.Engines
|
|||
}
|
||||
if (LabelSearch.IsSuccess)
|
||||
{
|
||||
Label = LabelSearch.Data;
|
||||
var addResult = await this.Add(Label);
|
||||
label = LabelSearch.Data;
|
||||
var addResult = await this.Add(label);
|
||||
if (!addResult.IsSuccess)
|
||||
{
|
||||
sw.Stop();
|
||||
|
@ -131,13 +125,13 @@ namespace Roadie.Library.Engines
|
|||
}
|
||||
else
|
||||
{
|
||||
this.CacheManager.Add(cacheKey, Label);
|
||||
this.CacheManager.Add(cacheKey, label);
|
||||
}
|
||||
return new OperationResult<Label>
|
||||
{
|
||||
IsSuccess = Label != null,
|
||||
IsSuccess = label != null,
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Data = Label
|
||||
Data = label
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -95,29 +95,15 @@ namespace Roadie.Library.Engines
|
|||
Data = resultInCache
|
||||
};
|
||||
}
|
||||
var getParams = new List<object>();
|
||||
var searchName = metaData.Release.NormalizeName().ToLower();
|
||||
var specialSearchName = metaData.Release.ToAlphanumericName();
|
||||
getParams.Add(new MySqlParameter("@artistId", artist.Id));
|
||||
getParams.Add(new MySqlParameter("@isTitle", searchName));
|
||||
getParams.Add(new MySqlParameter("@startAlt", string.Format("{0}|%", searchName)));
|
||||
getParams.Add(new MySqlParameter("@inAlt", string.Format("%|{0}|%", searchName)));
|
||||
getParams.Add(new MySqlParameter("@endAlt", string.Format("%|{0}", searchName)));
|
||||
getParams.Add(new MySqlParameter("@sstartAlt", string.Format("{0}|%", specialSearchName)));
|
||||
getParams.Add(new MySqlParameter("@sinAlt", string.Format("%|{0}|%", specialSearchName)));
|
||||
getParams.Add(new MySqlParameter("@sendAlt", string.Format("%|{0}", specialSearchName)));
|
||||
var release = this.DbContext.Releases.FromSql(@"SELECT *
|
||||
FROM `release`
|
||||
WHERE artistId = @artistId
|
||||
AND (LCASE(title) = @isTitle
|
||||
OR LCASE(alternatenames) = @isTitle
|
||||
OR alternatenames like @startAlt
|
||||
OR alternatenames like @sstartAlt
|
||||
OR alternatenames like @inAlt
|
||||
OR alternatenames like @sinAlt
|
||||
OR alternatenames like @endAlt
|
||||
OR alternatenames like @sendAlt)
|
||||
LIMIT 1", getParams.ToArray()).FirstOrDefault();
|
||||
var release = (from r in this.DbContext.Releases
|
||||
where (r.Title.Contains(searchName) ||
|
||||
r.AlternateNames.Contains(searchName) ||
|
||||
r.AlternateNames.Contains(specialSearchName))
|
||||
select r
|
||||
).FirstOrDefault();
|
||||
|
||||
sw.Stop();
|
||||
if (release == null || !release.IsValid)
|
||||
{
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="CsvHelper" Version="12.1.1" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="2.3.7" />
|
||||
<PackageReference Include="FluentFTP" Version="19.2.2" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.8.11" />
|
||||
<PackageReference Include="FluentFTP" Version="19.2.3" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.8.14" />
|
||||
<PackageReference Include="IdSharp.Common" Version="1.0.1" />
|
||||
<PackageReference Include="IdSharp.Tagging" Version="1.0.0-rc3" />
|
||||
<PackageReference Include="Inflatable.Lastfm" Version="1.1.0.339" />
|
||||
|
@ -21,7 +21,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
|
||||
<PackageReference Include="MimeMapping" Version="1.0.1.12" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" />
|
||||
<PackageReference Include="RestSharp" Version="106.6.5" />
|
||||
<PackageReference Include="RestSharp" Version="106.6.7" />
|
||||
<PackageReference Include="SixLabors.Core" Version="1.0.0-beta0006" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0005" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0005" />
|
||||
|
|
|
@ -348,7 +348,6 @@ namespace Roadie.Api.Services
|
|||
if (par != null)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
var modifiedDb = false;
|
||||
foreach (var csvRelease in par)
|
||||
{
|
||||
data.Release release = null;
|
||||
|
@ -390,14 +389,12 @@ namespace Roadie.Api.Services
|
|||
ReleaseId = release.Id,
|
||||
ListNumber = csvRelease.Position,
|
||||
});
|
||||
modifiedDb = true;
|
||||
}
|
||||
// If Item in Collection is at different List number update CollectionRelease
|
||||
else if (isInCollection.ListNumber != csvRelease.Position)
|
||||
{
|
||||
isInCollection.LastUpdated = now;
|
||||
isInCollection.ListNumber = csvRelease.Position;
|
||||
modifiedDb = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -183,11 +183,12 @@ namespace Roadie.Api.Services
|
|||
request.Filter = null;
|
||||
}
|
||||
var onlyWithReleases = onlyIncludeWithReleases ?? true;
|
||||
var normalizedFilterValue = !string.IsNullOrEmpty(request.FilterValue) ? request.FilterValue.ToAlphanumericName() : null;
|
||||
var result = (from a in this.DbContext.Artists
|
||||
where (!onlyWithReleases || a.ReleaseCount > 0)
|
||||
where (request.FilterToArtistId == null || a.RoadieId == request.FilterToArtistId)
|
||||
where (request.FilterMinimumRating == null || a.Rating >= request.FilterMinimumRating.Value)
|
||||
where (request.FilterValue == "" || (a.Name.Contains(request.FilterValue) || a.SortName.Contains(request.FilterValue) || a.AlternateNames.Contains(request.FilterValue)))
|
||||
where (request.FilterValue == "" || (a.Name.Contains(request.FilterValue) || a.SortName.Contains(request.FilterValue) || a.AlternateNames.Contains(request.FilterValue) || a.AlternateNames.Contains(normalizedFilterValue)))
|
||||
where (!request.FilterFavoriteOnly || favoriteArtistIds.Contains(a.Id))
|
||||
where (request.FilterToLabelId == null || labelArtistIds.Contains(a.Id))
|
||||
where (!isFilteredToGenre || genreArtistIds.Contains(a.Id))
|
||||
|
|
|
@ -77,10 +77,12 @@ namespace Roadie.Api.Services
|
|||
request.Sort = request.Sort.Replace("createdDate", "createdDateTime");
|
||||
request.Sort = request.Sort.Replace("lastUpdated", "lastUpdatedDateTime");
|
||||
}
|
||||
var normalizedFilterValue = !string.IsNullOrEmpty(request.FilterValue) ? request.FilterValue.ToAlphanumericName() : null;
|
||||
var result = (from l in this.DbContext.Labels
|
||||
where (request.FilterValue.Length == 0 || (request.FilterValue.Length > 0 && (
|
||||
l.Name != null && l.Name.Contains(request.FilterValue) ||
|
||||
l.AlternateNames != null && l.AlternateNames.Contains(request.FilterValue)
|
||||
l.AlternateNames != null && l.AlternateNames.Contains(request.FilterValue) ||
|
||||
l.AlternateNames != null && l.AlternateNames.Contains(normalizedFilterValue)
|
||||
)))
|
||||
select new LabelList
|
||||
{
|
||||
|
|
|
@ -222,6 +222,7 @@ namespace Roadie.Api.Services
|
|||
//
|
||||
// TODO list should honor disliked artist and albums for random
|
||||
//
|
||||
var normalizedFilterValue = !string.IsNullOrEmpty(request.FilterValue) ? request.FilterValue.ToAlphanumericName() : null;
|
||||
var result = (from r in this.DbContext.Releases
|
||||
join a in this.DbContext.Artists on r.ArtistId equals a.Id
|
||||
where (request.FilterMinimumRating == null || r.Rating >= request.FilterMinimumRating.Value)
|
||||
|
@ -231,7 +232,7 @@ namespace Roadie.Api.Services
|
|||
where (!isFilteredToGenre || genreReleaseIds.Contains(r.Id))
|
||||
where (request.FilterFromYear == null || r.ReleaseDate != null && r.ReleaseDate.Value.Year <= request.FilterFromYear)
|
||||
where (request.FilterToYear == null || r.ReleaseDate != null && r.ReleaseDate.Value.Year >= request.FilterToYear)
|
||||
where (request.FilterValue == "" || (r.Title.Contains(request.FilterValue) || r.AlternateNames.Contains(request.FilterValue)))
|
||||
where (request.FilterValue == "" || (r.Title.Contains(request.FilterValue) || r.AlternateNames.Contains(request.FilterValue) || r.AlternateNames.Contains(normalizedFilterValue)))
|
||||
select new ReleaseList
|
||||
{
|
||||
DatabaseId = r.Id,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Hashids.net" Version="1.2.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.3.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.4.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.9.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -262,6 +262,7 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
filterToTrackIds = f.ToArray();
|
||||
}
|
||||
var normalizedFilterValue = !string.IsNullOrEmpty(request.FilterValue) ? request.FilterValue.ToAlphanumericName() : null;
|
||||
// Did this for performance against the Track table, with just * selcts the table scans are too much of a performance hit.
|
||||
var resultQuery = (from t in this.DbContext.Tracks
|
||||
join rm in this.DbContext.ReleaseMedias on t.ReleaseMediaId equals rm.Id
|
||||
|
@ -273,7 +274,7 @@ namespace Roadie.Api.Services
|
|||
where (releaseId == null || (releaseId != null && r.RoadieId == releaseId))
|
||||
where (filterToTrackIds == null || filterToTrackIds.Contains(t.RoadieId))
|
||||
where (request.FilterMinimumRating == null || t.Rating >= request.FilterMinimumRating.Value)
|
||||
where (request.FilterValue == "" || (t.Title.Contains(request.FilterValue) || t.AlternateNames.Contains(request.FilterValue)))
|
||||
where (request.FilterValue == "" || (t.Title.Contains(request.FilterValue) || t.AlternateNames.Contains(request.FilterValue) || t.AlternateNames.Contains(normalizedFilterValue)))
|
||||
where (!request.FilterFavoriteOnly || favoriteTrackIds.Contains(t.Id))
|
||||
where (request.FilterToPlaylistId == null || playlistTrackIds.Contains(t.Id))
|
||||
where (!request.FilterTopPlayedOnly || topTrackids.Contains(t.Id))
|
||||
|
|
|
@ -79,14 +79,6 @@ namespace Roadie.Api.Services
|
|||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
if (!string.IsNullOrEmpty(request.Sort))
|
||||
{
|
||||
request.Sort = request.Sort.Replace("createdDate", "createdDateTime");
|
||||
request.Sort = request.Sort.Replace("lastLogin", "lastUpdatedDateTime");
|
||||
request.Sort = request.Sort.Replace("lastApiAccess", "lastApiAccessDateTime");
|
||||
request.Sort = request.Sort.Replace("registeredOn", "registeredDateTime");
|
||||
}
|
||||
|
||||
var result = (from u in this.DbContext.Users
|
||||
where (request.FilterValue.Length == 0 || (request.FilterValue.Length > 0 && (u.UserName.Contains(request.FilterValue))))
|
||||
select new UserList
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"Roadie.Api": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
"ASPNETCORE_ENVIRONMENT": "Production"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5123/"
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
|
||||
<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.3.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.4.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.9.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Loading…
Reference in a new issue