Skip to content

Commit

Permalink
Merge pull request #22 from ScoopInstaller/notes-field
Browse files Browse the repository at this point in the history
Index Notes field from manifests
  • Loading branch information
gpailler authored May 5, 2024
2 parents 92fe91c + c7395ab commit 38d6acd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ScoopSearch.Indexer.Tests/Helpers/Faker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static Faker<ManifestInfo> CreateManifestInfo(Action<Faker<ManifestMetada
.RuleFor(_ => _.NamePartial, (f, o) => o.Name)
.RuleFor(_ => _.NameSuffix, (f, o) => o.Name)
.RuleFor(_ => _.Description, f => f.Lorem.Sentences())
.RuleFor(_ => _.Notes, f => f.Lorem.Sentences())
.RuleFor(_ => _.Homepage, f => f.Internet.Url())
.RuleFor(_ => _.License, f => f.PickRandomParam("MIT", "BSD", "GPL", "Custom"))
.RuleFor(_ => _.Version, f => f.System.Semver())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@ public void Deserialize_Description_Succeeds(string jsonContent, string? expecte
result!.Description.Should().Be(expectedResult?.Replace("\n", Environment.NewLine));
}

[Theory]
[InlineData("", null)]
[InlineData(@"""notes"": """"", "")]
[InlineData(@"""notes"": ""foo""", "foo")]
[InlineData(@"""notes"": [ ""foo"" ]", "foo")]
[InlineData(@"""notes"": [ ""foo"", ""bar"" ]", "foo bar")]
[InlineData(@"""notes"": [ ""foo"", """", ""bar"" ]", "foo \n bar")]
public void Deserialize_Notes_Succeeds(string jsonContent, string? expectedResult)
{
// Arrange
jsonContent = $"{{ {jsonContent} }}";

// Act
var result = ManifestInfo.Deserialize(jsonContent, "foo", new ManifestMetadata());

// Assert
result.Should().NotBeNull();
result!.Notes.Should().Be(expectedResult?.Replace("\n", Environment.NewLine));
}

[Theory]
[InlineData("", null)]
[InlineData(@"""version"": """"", "")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace ScoopSearch.Indexer.Data.JsonConverter;

internal class DescriptionConverter : JsonConverter<string?>
internal class MultiLineStringConverter : JsonConverter<string?>
{
public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
Expand Down
7 changes: 6 additions & 1 deletion src/ScoopSearch.Indexer/Data/ManifestInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ public class ManifestInfo
public string? NameSuffix { get; private set; }

[SearchableField(AnalyzerName = LexicalAnalyzerName.Values.EnLucene)]
[JsonConverter(typeof(DescriptionConverter))]
[JsonConverter(typeof(MultiLineStringConverter))]
[JsonInclude]
public string? Description { get; private set; }

[SearchableField(AnalyzerName = LexicalAnalyzerName.Values.EnLucene)]
[JsonConverter(typeof(MultiLineStringConverter))]
[JsonInclude]
public string? Notes { get; private set; }

Check warning on line 52 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Notes'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 52 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Notes'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 52 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Notes'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 52 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Notes'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 52 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Notes'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 52 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Notes'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

[SearchableField(IsFilterable = true, IsSortable = true, IsFacetable = true, AnalyzerName = AzureSearchIndex.UrlAnalyzer)]
[JsonInclude]
public string? Homepage { get; private set; }

Check warning on line 56 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Homepage'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 56 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Homepage'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 56 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Homepage'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 56 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Homepage'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 56 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Homepage'. (https://rules.sonarsource.com/csharp/RSPEC-1144)

Check warning on line 56 in src/ScoopSearch.Indexer/Data/ManifestInfo.cs

View workflow job for this annotation

GitHub Actions / Tests ⚙️🧪

Remove the unused private setter 'set_Homepage'. (https://rules.sonarsource.com/csharp/RSPEC-1144)
Expand Down

0 comments on commit 38d6acd

Please sign in to comment.