Skip to content

Commit

Permalink
make get base settings an async method
Browse files Browse the repository at this point in the history
  • Loading branch information
samihafidiDLW committed Aug 1, 2024
1 parent 4a56a12 commit 53443ba
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>$(Company)</Authors>
<Copyright>Copyright © $(Company) $([System.DateTime]::Now.Year)</Copyright>
<Trademark>$(Company)™</Trademark>
<VersionPrefix>1.0.3-beta-1</VersionPrefix>
<VersionPrefix>1.0.4-beta-1</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Expand Down
4 changes: 2 additions & 2 deletions examples/DancingGoat/Search/SimpleSearchIndexingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class SimpleSearchCollectionStrategy : DefaultTypesenseCollectionStrategy
private readonly IWebPageQueryResultMapper webPageMapper;
private readonly IContentQueryExecutor queryExecutor;

public override ITypesenseCollectionSettings GetTypesenseCollectionSettings()
public override async Task<ITypesenseCollectionSettings> GetTypesenseCollectionSettings()
{
var baseSettings = base.GetTypesenseCollectionSettings();
var baseSettings = await base.GetTypesenseCollectionSettings();
baseSettings.Fields.Add(new Field(nameof(SimpleSearchResultModel.Title), FieldType.String, false));
return baseSettings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public async Task<bool> TryCreateCollection(ITypesenseConfigurationModel configu
var typesenseCollection = TypesenseCollectionStore.Instance.GetCollection(configuration.CollectionName) ?? throw new InvalidOperationException($"Registered index with name '{configuration.CollectionName}' doesn't exist.");

var typesenseStrategy = serviceProvider.GetRequiredStrategy(typesenseCollection);
var indexSettings = typesenseStrategy.GetTypesenseCollectionSettings();
var indexSettings = await typesenseStrategy.GetTypesenseCollectionSettings();

var createdCollection = await searchClient.CreateCollection(indexSettings.ToSchema($"{configuration.CollectionName}-primary"));
if (createdCollection == null)
Expand All @@ -353,7 +353,7 @@ public async Task<bool> TryEditCollection(ITypesenseConfigurationModel configura
var typesenseCollection = TypesenseCollectionStore.Instance.GetCollection(configuration.CollectionName) ?? throw new InvalidOperationException($"Registered index with name '{configuration.CollectionName}' doesn't exist.");

var typesenseStrategy = serviceProvider.GetRequiredStrategy(typesenseCollection);
var indexSettings = typesenseStrategy.GetTypesenseCollectionSettings();
var indexSettings = await typesenseStrategy.GetTypesenseCollectionSettings();

var currentCollection = await searchClient.RetrieveCollection(configuration.CollectionName); //Search by alias the current collection

Expand All @@ -379,7 +379,7 @@ public async Task<bool> TryEditCollection(ITypesenseConfigurationModel configura
public async Task<bool> EnsureNewCollection(string newCollection, TypesenseCollection typesenseCollection)
{
var typesenseStrategy = serviceProvider.GetRequiredStrategy(typesenseCollection);
var indexSettings = typesenseStrategy.GetTypesenseCollectionSettings();
var indexSettings = await typesenseStrategy.GetTypesenseCollectionSettings();

var allCollections = await searchClient.RetrieveCollections();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public class DefaultTypesenseCollectionStrategy : ITypesenseCollectionStrategy
return Task.FromResult<IEnumerable<TypesenseSearchResultModel>?>(result);
}

public virtual ITypesenseCollectionSettings GetTypesenseCollectionSettings() => new TypesenseCollectionSettings()
{
Fields =
[
public virtual Task<ITypesenseCollectionSettings> GetTypesenseCollectionSettings() =>
Task.FromResult<ITypesenseCollectionSettings>(new TypesenseCollectionSettings()
{
Fields = new(){
new Field(BaseObjectProperties.ITEM_GUID, FieldType.String),
new Field(BaseObjectProperties.CONTENT_TYPE_NAME, FieldType.String),
new Field(BaseObjectProperties.LANGUAGE_NAME, FieldType.String),
new Field(BaseObjectProperties.URL, FieldType.String),
]
};
}
});

public virtual async Task<IEnumerable<ICollectionEventItemModel>> FindItemsToReindex(CollectionEventWebPageItemModel changedItem) => await Task.FromResult(new List<CollectionEventWebPageItemModel>() { changedItem });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface ITypesenseCollectionStrategy
/// <returns>Modified Typesense document.</returns>
Task<IEnumerable<TypesenseSearchResultModel>?> MapToTypesenseObjectsOrNull(ICollectionEventItemModel typesensePageItem);

ITypesenseCollectionSettings GetTypesenseCollectionSettings();
Task<ITypesenseCollectionSettings> GetTypesenseCollectionSettings();

Task<IEnumerable<ICollectionEventItemModel>> FindItemsToReindex(CollectionEventWebPageItemModel changedItem);

Expand Down

0 comments on commit 53443ba

Please sign in to comment.