Skip to content

Commit b76ae01

Browse files
committed
PR updates and filtering for content that is not deleted
1 parent 68edc40 commit b76ae01

11 files changed

+30
-32
lines changed

src/Umbraco.Cms.Integrations.Search.Algolia/Controllers/SearchController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public async Task<IActionResult> BuildIndex([FromBody] IndexConfiguration indexC
134134

135135
_logger.LogInformation("Building index for {ContentType} with {Count} items", contentDataItem.ContentType.Alias, contentItems.Count());
136136

137-
foreach (var contentItem in contentItems)
137+
foreach (var contentItem in contentItems.Where(p => !p.Trashed))
138138
{
139139
var record = new ContentRecordBuilder(_userService, _urlProvider, _algoliaSearchPropertyIndexValueFactory)
140140
.BuildFromContent(contentItem, (p) => contentDataItem.Properties.Any(q => q.Alias == p.Alias))

src/Umbraco.Cms.Integrations.Search.Algolia/Converters/IConverter.cs renamed to src/Umbraco.Cms.Integrations.Search.Algolia/Converters/IAlgoliaIndexValueConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
/// <summary>
44
/// Defines a custom index converter.
55
/// </summary>
6-
public interface IConverter
6+
public interface IAlgoliaIndexValueConverter
77
{
88
/// <summary>
99
/// Gets the name of the converter.
1010
/// </summary>
1111
string Name { get; }
1212

1313
/// <summary>
14-
/// Parses the index value.
14+
/// Parses the index values.
1515
/// </summary>
16-
object ParseIndexValue(KeyValuePair<string, IEnumerable<object>> indexValue);
16+
object ParseIndexValues(IEnumerable<object> indexValues);
1717
}
1818
}

src/Umbraco.Cms.Integrations.Search.Algolia/Converters/UmbracoBooleanConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
22
{
3-
public class UmbracoBooleanConverter : IConverter
3+
public class UmbracoBooleanConverter : IAlgoliaIndexValueConverter
44
{
55
public string Name => Core.Constants.PropertyEditors.Aliases.Boolean;
66

7-
public object ParseIndexValue(KeyValuePair<string, IEnumerable<object>> indexValue)
7+
public object ParseIndexValues(IEnumerable<object> indexValues)
88
{
9-
if (indexValue.Value != null && indexValue.Value.Any())
9+
if (indexValues != null && indexValues.Any())
1010
{
11-
var value = indexValue.Value.FirstOrDefault();
11+
var value = indexValues.FirstOrDefault();
1212

1313
return value != null
1414
? value.Equals(1)

src/Umbraco.Cms.Integrations.Search.Algolia/Converters/UmbracoDecimalConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
22
{
3-
public class UmbracoDecimalConverter : IConverter
3+
public class UmbracoDecimalConverter : IAlgoliaIndexValueConverter
44
{
55
public string Name => Core.Constants.PropertyEditors.Aliases.Decimal;
66

7-
public object ParseIndexValue(KeyValuePair<string, IEnumerable<object>> indexValue)
7+
public object ParseIndexValues(IEnumerable<object> indexValues)
88
{
9-
if (indexValue.Value != null && indexValue.Value.Any())
9+
if (indexValues != null && indexValues.Any())
1010
{
11-
var value = indexValue.Value.FirstOrDefault();
11+
var value = indexValues.FirstOrDefault();
1212

1313
return value != null
1414
? decimal.Parse(value.ToString())

src/Umbraco.Cms.Integrations.Search.Algolia/Converters/UmbracoIntegerConverter.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
using System.Windows.Markup;
2-
3-
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
1+
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
42
{
5-
public class UmbracoIntegerConverter : IConverter
3+
public class UmbracoIntegerConverter : IAlgoliaIndexValueConverter
64
{
75
public string Name => Core.Constants.PropertyEditors.Aliases.Integer;
86

9-
public object ParseIndexValue(KeyValuePair<string, IEnumerable<object>> indexValue)
7+
public object ParseIndexValues(IEnumerable<object> indexValues)
108
{
11-
if (indexValue.Value != null && indexValue.Value.Any())
9+
if (indexValues != null && indexValues.Any())
1210
{
13-
var value = indexValue.Value.FirstOrDefault();
11+
var value = indexValues.FirstOrDefault();
1412

1513
return value ?? default(int);
1614
}

src/Umbraco.Cms.Integrations.Search.Algolia/Converters/UmbracoMediaPickerConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
55
{
6-
public class UmbracoMediaPickerConverter : IConverter
6+
public class UmbracoMediaPickerConverter : IAlgoliaIndexValueConverter
77
{
88
private readonly IMediaService _mediaService;
99

1010
public UmbracoMediaPickerConverter(IMediaService mediaService) => _mediaService = mediaService;
1111

1212
public string Name => Core.Constants.PropertyEditors.Aliases.MediaPicker3;
1313

14-
public object ParseIndexValue(KeyValuePair<string, IEnumerable<object>> indexValue)
14+
public object ParseIndexValues(IEnumerable<object> indexValues)
1515
{
1616
var list = new List<string>();
1717

18-
var parsedIndexValue = ParseIndexValue(indexValue.Value);
18+
var parsedIndexValue = ParseIndexValue(indexValues);
1919

2020
if (string.IsNullOrEmpty(parsedIndexValue)) return list;
2121

src/Umbraco.Cms.Integrations.Search.Algolia/Converters/UmbracoTagsConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
44
{
5-
public class UmbracoTagsConverter : IConverter
5+
public class UmbracoTagsConverter : IAlgoliaIndexValueConverter
66
{
77
public string Name => Core.Constants.PropertyEditors.Aliases.Tags;
88

9-
public object ParseIndexValue(KeyValuePair<string, IEnumerable<object>> indexValue)
9+
public object ParseIndexValues(IEnumerable<object> indexValues)
1010
{
11-
if (indexValue.Value != null && indexValue.Value.Any())
11+
if (indexValues != null && indexValues.Any())
1212
{
13-
return indexValue.Value;
13+
return indexValues;
1414
}
1515

1616
return Enumerable.Empty<string>();

src/Umbraco.Cms.Integrations.Search.Algolia/Providers/ConverterCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace Umbraco.Cms.Integrations.Search.Algolia.Providers
55
{
6-
public class ConverterCollection : BuilderCollectionBase<IConverter>
6+
public class ConverterCollection : BuilderCollectionBase<IAlgoliaIndexValueConverter>
77
{
8-
public ConverterCollection(Func<IEnumerable<IConverter>> items)
8+
public ConverterCollection(Func<IEnumerable<IAlgoliaIndexValueConverter>> items)
99
: base(items)
1010
{
1111
}

src/Umbraco.Cms.Integrations.Search.Algolia/Providers/ConverterCollectionBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Umbraco.Cms.Integrations.Search.Algolia.Providers
55
{
6-
public class ConverterCollectionBuilder : OrderedCollectionBuilderBase<ConverterCollectionBuilder, ConverterCollection, IConverter>
6+
public class ConverterCollectionBuilder : OrderedCollectionBuilderBase<ConverterCollectionBuilder, ConverterCollection, IAlgoliaIndexValueConverter>
77
{
88
protected override ConverterCollectionBuilder This => this;
99
}

src/Umbraco.Cms.Integrations.Search.Algolia/Services/AlgoliaSearchPropertyIndexValueFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public virtual KeyValuePair<string, object> GetValue(IProperty property, string
3737
var converter = _converterCollection.FirstOrDefault(p => p.Name == property.PropertyType.PropertyEditorAlias);
3838
if (converter != null)
3939
{
40-
var result = converter.ParseIndexValue(indexValue);
40+
var result = converter.ParseIndexValues(indexValue.Value);
4141
return new KeyValuePair<string, object>(property.Alias, result);
4242
}
4343

44-
return new KeyValuePair<string, object>(indexValue.Key, indexValue.Value);
44+
return new KeyValuePair<string, object>(property.Alias, indexValue.Value);
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)