Fixed: Sort by Downloaded not working.

Fixes #2195
pull/2/head
Leonardo Galli 7 years ago
parent 56acf751c5
commit d2b6b603a8

@ -102,7 +102,7 @@ namespace NzbDrone.Core.Tv
return pagingSpec; return pagingSpec;
} }
public override PagingSpec<Movie> GetPaged(PagingSpec<Movie> pagingSpec) /*public override PagingSpec<Movie> GetPaged(PagingSpec<Movie> pagingSpec)
{ {
if (pagingSpec.SortKey == "downloadedQuality") if (pagingSpec.SortKey == "downloadedQuality")
{ {
@ -118,9 +118,10 @@ namespace NzbDrone.Core.Tv
var q2 = mapper.Query<Movie>("SELECT * from \"Movies\" , \"MovieFiles\", \"QualityDefinitions\" WHERE Movies.MovieFileId=MovieFiles.Id AND instr(MovieFiles.Quality, ('quality\": ' || QualityDefinitions.Quality || \",\")) > 0 ORDER BY QualityDefinitions.Title ASC;"); var q2 = mapper.Query<Movie>("SELECT * from \"Movies\" , \"MovieFiles\", \"QualityDefinitions\" WHERE Movies.MovieFileId=MovieFiles.Id AND instr(MovieFiles.Quality, ('quality\": ' || QualityDefinitions.Quality || \",\")) > 0 ORDER BY QualityDefinitions.Title ASC;");
//var ok = q.BuildQuery(); //var ok = q.BuildQuery();
var q3 = Query.OrderBy("json_extract([t2].[quality], '$.quality') DESC");
pagingSpec.Records = q.ToList(); pagingSpec.Records = q3.ToList();
pagingSpec.TotalRecords = q2.Count(); pagingSpec.TotalRecords = q3.GetRowCount();
} }
else else
@ -138,7 +139,7 @@ namespace NzbDrone.Core.Tv
} }
return pagingSpec; return pagingSpec;
} }*/
/*protected override SortBuilder<Movie> GetPagedQuery(QueryBuilder<Movie> query, PagingSpec<Movie> pagingSpec) /*protected override SortBuilder<Movie> GetPagedQuery(QueryBuilder<Movie> query, PagingSpec<Movie> pagingSpec)
{ {
@ -184,7 +185,9 @@ namespace NzbDrone.Core.Tv
var q = mapper.Query<Movie>($"SELECT * from \"Movies\" , \"MovieFiles\", \"QualityDefinitions\" WHERE Movies.MovieFileId=MovieFiles.Id AND instr(MovieFiles.Quality, ('quality\": ' || QualityDefinitions.Quality || \",\")) > 0 AND {whereClause} ORDER BY QualityDefinitions.Title {direction} LIMIT {offset},{limit};"); var q = mapper.Query<Movie>($"SELECT * from \"Movies\" , \"MovieFiles\", \"QualityDefinitions\" WHERE Movies.MovieFileId=MovieFiles.Id AND instr(MovieFiles.Quality, ('quality\": ' || QualityDefinitions.Quality || \",\")) > 0 AND {whereClause} ORDER BY QualityDefinitions.Title {direction} LIMIT {offset},{limit};");
var q2 = mapper.Query<Movie>($"SELECT * from \"Movies\" , \"MovieFiles\", \"QualityDefinitions\" WHERE Movies.MovieFileId=MovieFiles.Id AND instr(MovieFiles.Quality, ('quality\": ' || QualityDefinitions.Quality || \",\")) > 0 AND {whereClause} ORDER BY QualityDefinitions.Title ASC;"); var q2 = mapper.Query<Movie>($"SELECT * from \"Movies\" , \"MovieFiles\", \"QualityDefinitions\" WHERE Movies.MovieFileId=MovieFiles.Id AND instr(MovieFiles.Quality, ('quality\": ' || QualityDefinitions.Quality || \",\")) > 0 AND {whereClause} ORDER BY QualityDefinitions.Title ASC;");
//var ok = q.BuildQuery(); var q3 = Query.OrderBy(m => m.MovieFile.Quality.Quality);
var ok = q3.BuildQuery();
var t = ok;
pagingSpec.Records = q.ToList(); pagingSpec.Records = q.ToList();
pagingSpec.TotalRecords = q2.Count(); pagingSpec.TotalRecords = q2.Count();

@ -63,7 +63,7 @@ module.exports = Marionette.Layout.extend({
cell : RelativeDateCell cell : RelativeDateCell
}, },
{ {
name : "downloadedQuality", name : "movieFile.quality",
label : "Downloaded", label : "Downloaded",
cell : DownloadedQualityCell, cell : DownloadedQualityCell,
sortable : true sortable : true
@ -215,7 +215,7 @@ module.exports = Marionette.Layout.extend({
}, },
{ {
title: 'Downloaded', title: 'Downloaded',
name: 'downloadedQuality' name: 'movieFile.quality'
}, },
{ {
title : 'Profile', title : 'Profile',

Loading…
Cancel
Save