Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Orchard.Projections.Descriptors.Layout;
using Orchard.Projections.Descriptors.Property;
using Orchard.Projections.Descriptors.SortCriterion;
using Orchard.Projections.Models;

namespace Orchard.Projections.Services
{
Expand All @@ -23,7 +24,12 @@ public interface IProjectionManager : IDependency
IEnumerable<ContentItem> GetContentItems(int queryId, int skip = 0, int count = 0);
IEnumerable<ContentItem> GetContentItems(int queryId, ContentPart part, int skip = 0, int count = 0);

IEnumerable<IHqlQuery> GetContentQueries(
QueryPartRecord queryRecord,
IEnumerable<SortCriterionRecord> sortCriteria,
Dictionary<string, object> tokens);

int GetCount(int queryId);
int GetCount(int queryId, ContentPart part);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public int GetCount(int queryId, ContentPart part)
var queryRecord = _queryRepository.Get(queryId) ?? throw new ArgumentException("queryId");

// Prepare tokens.
Dictionary<string, object> tokens = new Dictionary<string, object>();
var tokens = new Dictionary<string, object>();
if (part != null)
{
tokens.Add("Content", part.ContentItem);
Expand All @@ -151,17 +151,11 @@ public IEnumerable<ContentItem> GetContentItems(int queryId, ContentPart part, i
{
var availableSortCriteria = DescribeSortCriteria().ToList();

var queryRecord = _queryRepository.Get(queryId);

if (queryRecord == null)
{
throw new ArgumentException("queryId");
}

var queryRecord = _queryRepository.Get(queryId) ?? throw new ArgumentException("queryId");
var contentItems = new List<ContentItem>();

// Prepare tokens.
Dictionary<string, object> tokens = new Dictionary<string, object>();
var tokens = new Dictionary<string, object>();
if (part != null)
{
tokens.Add("Content", part.ContentItem);
Expand All @@ -186,7 +180,8 @@ public IEnumerable<ContentItem> GetContentItems(int queryId, ContentPart part, i
return Enumerable.Empty<ContentItem>();
}

var groupQuery = _contentManager.HqlQuery().Where(alias => alias.Named("ci"), x => x.InG("Id", ids));
var version = queryRecord.VersionScope.ToVersionOptions();
var groupQuery = _contentManager.HqlQuery().ForVersion(version).Where(alias => alias.Named("ci"), x => x.InG("Id", ids));

// Iterate over each sort criteria to apply the alterations to the query object.
foreach (var sortCriterion in queryRecord.SortCriteria.OrderBy(s => s.Position))
Expand All @@ -200,8 +195,8 @@ public IEnumerable<ContentItem> GetContentItems(int queryId, ContentPart part, i
Tokens = tokens
};

string category = sortCriterion.Category;
string type = sortCriterion.Type;
var category = sortCriterion.Category;
var type = sortCriterion.Type;

// Find specific sort criterion.
var descriptor = availableSortCriteria
Expand Down Expand Up @@ -255,8 +250,8 @@ public IEnumerable<IHqlQuery> GetContentQueries(
Tokens = tokens
};

string category = filter.Category;
string type = filter.Type;
var category = filter.Category;
var type = filter.Type;

// Find specific filter.
var descriptor = availableFilters
Expand Down Expand Up @@ -287,8 +282,8 @@ public IEnumerable<IHqlQuery> GetContentQueries(
Tokens = tokens
};

string category = sortCriterion.Category;
string type = sortCriterion.Type;
var category = sortCriterion.Category;
var type = sortCriterion.Type;

// Find specific sort criterion.
var descriptor = availableSortCriteria
Expand Down