Changes published index flag to y/n instead of 1/0

This commit is contained in:
Shannon
2019-01-08 14:04:37 +11:00
parent 4a1ae0573f
commit 340a7e5383
3 changed files with 12 additions and 12 deletions

View File

@@ -42,7 +42,7 @@ namespace Umbraco.Examine
var values = new Dictionary<string, IEnumerable<object>>
{
{"icon", c.ContentType.Icon.Yield()},
{UmbracoExamineIndex.PublishedFieldName, new object[] {c.Published ? 1 : 0}}, //Always add invariant published value
{UmbracoExamineIndex.PublishedFieldName, new object[] {c.Published ? "y" : "n"}}, //Always add invariant published value
{"id", new object[] {c.Id}},
{UmbracoExamineIndex.NodeKeyFieldName, new object[] {c.Key}},
{"parentID", new object[] {c.Level > 1 ? c.ParentId : -1}},
@@ -76,7 +76,7 @@ namespace Umbraco.Examine
values[$"nodeName_{lowerCulture}"] = PublishedValuesOnly
? c.GetPublishName(culture).Yield()
: c.GetCultureName(culture).Yield();
values[$"{UmbracoExamineIndex.PublishedFieldName}_{lowerCulture}"] = (c.IsCulturePublished(culture) ? 1 : 0).Yield<object>();
values[$"{UmbracoExamineIndex.PublishedFieldName}_{lowerCulture}"] = (c.IsCulturePublished(culture) ? "y" : "n").Yield<object>();
values[$"updateDate_{lowerCulture}"] = PublishedValuesOnly
? c.GetPublishDate(culture).Yield<object>()
: c.GetUpdateDate(culture).Yield<object>();

View File

@@ -95,7 +95,7 @@ namespace Umbraco.Examine
if (!valueSet.Values.TryGetValue(UmbracoExamineIndex.PublishedFieldName, out var published))
return ValueSetValidationResult.Failed;
if (!published[0].Equals(1))
if (!published[0].Equals("y"))
return ValueSetValidationResult.Failed;
//deal with variants, if there are unpublished variants than we need to remove them from the value set
@@ -105,7 +105,7 @@ namespace Umbraco.Examine
//so this valueset is for a content that varies by culture, now check for non-published cultures and remove those values
foreach(var publishField in valueSet.Values.Where(x => x.Key.StartsWith($"{UmbracoExamineIndex.PublishedFieldName}_")).ToList())
{
if (publishField.Value.Count <= 0 || !publishField.Value[0].Equals(1))
if (publishField.Value.Count <= 0 || !publishField.Value[0].Equals("y"))
{
//this culture is not published, so remove all of these culture values
var cultureSuffix = publishField.Key.Substring(publishField.Key.LastIndexOf('_'));

View File

@@ -179,7 +179,7 @@ namespace Umbraco.Tests.UmbracoExamine
{
["hello"] = "world",
["path"] = "-1,555",
[UmbracoExamineIndex.PublishedFieldName] = 1
[UmbracoExamineIndex.PublishedFieldName] = "y"
}));
Assert.AreEqual(ValueSetValidationResult.Valid, result);
}
@@ -213,7 +213,7 @@ namespace Umbraco.Tests.UmbracoExamine
{
["hello"] = "world",
["path"] = "-1,555",
[UmbracoExamineIndex.PublishedFieldName] = 0
[UmbracoExamineIndex.PublishedFieldName] = "n"
}));
Assert.AreEqual(ValueSetValidationResult.Failed, result);
@@ -222,7 +222,7 @@ namespace Umbraco.Tests.UmbracoExamine
{
["hello"] = "world",
["path"] = "-1,555",
[UmbracoExamineIndex.PublishedFieldName] = 1
[UmbracoExamineIndex.PublishedFieldName] = "y"
}));
Assert.AreEqual(ValueSetValidationResult.Valid, result);
}
@@ -238,7 +238,7 @@ namespace Umbraco.Tests.UmbracoExamine
["hello"] = "world",
["path"] = "-1,555",
[UmbracoContentIndex.VariesByCultureFieldName] = "y",
[UmbracoExamineIndex.PublishedFieldName] = 0
[UmbracoExamineIndex.PublishedFieldName] = "n"
}));
Assert.AreEqual(ValueSetValidationResult.Failed, result);
@@ -248,7 +248,7 @@ namespace Umbraco.Tests.UmbracoExamine
["hello"] = "world",
["path"] = "-1,555",
[UmbracoContentIndex.VariesByCultureFieldName] = "y",
[UmbracoExamineIndex.PublishedFieldName] = 1
[UmbracoExamineIndex.PublishedFieldName] = "y"
}));
Assert.AreEqual(ValueSetValidationResult.Valid, result);
@@ -258,13 +258,13 @@ namespace Umbraco.Tests.UmbracoExamine
["hello"] = "world",
["path"] = "-1,555",
[UmbracoContentIndex.VariesByCultureFieldName] = "y",
[$"{UmbracoExamineIndex.PublishedFieldName}_en-us"] = 1,
[$"{UmbracoExamineIndex.PublishedFieldName}_en-us"] = "y",
["hello_en-us"] = "world",
["title_en-us"] = "my title",
[$"{UmbracoExamineIndex.PublishedFieldName}_es-es"] = 0,
[$"{UmbracoExamineIndex.PublishedFieldName}_es-es"] = "n",
["hello_es-ES"] = "world",
["title_es-ES"] = "my title",
[UmbracoExamineIndex.PublishedFieldName] = 1
[UmbracoExamineIndex.PublishedFieldName] = "y"
});
Assert.AreEqual(10, valueSet.Values.Count());
Assert.IsTrue(valueSet.Values.ContainsKey($"{UmbracoExamineIndex.PublishedFieldName}_es-es"));