Skip to content

Commit

Permalink
Indexing delete node
Browse files Browse the repository at this point in the history
  • Loading branch information
kapustb committed Oct 20, 2023
1 parent c58ef94 commit e76b712
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/AlgoliaSearchModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ protected override void OnInit()

DocumentEvents.Delete.Before += HandleDocumentEvent;
DocumentEvents.Update.Before += HandleDocumentEvent;
DocumentEvents.Update.After += ForceMoveUpdate;
DocumentEvents.Delete.After += ForceMoveUpdate;
DocumentEvents.Update.Before += ForceMoveUpdate;
DocumentEvents.Delete.Before += ForceDelete;
DocumentEvents.Insert.After += HandleDocumentEvent;
WorkflowEvents.Publish.After += HandleWorkflowEvent;
WorkflowEvents.Archive.After += HandleWorkflowEvent;
Expand Down Expand Up @@ -120,5 +120,14 @@ private void ForceMoveUpdate(object sender, DocumentEventArgs e)
algoliaTaskLogger.HandleEventAfter(e.Node, e.CurrentHandler.Name);
}
}

private void ForceDelete(object sender, DocumentEventArgs e)
{
if (!EventShouldContinue(e.Node))
{
return;
}
algoliaTaskLogger.HandleEventAfter(e.Node, e.CurrentHandler.Name);
}
}
}
7 changes: 6 additions & 1 deletion src/Services/Implementations/DefaultAlgoliaTaskLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ internal class DefaultAlgoliaTaskLogger : IAlgoliaTaskLogger
{
private readonly IEventLogService eventLogService;


public DefaultAlgoliaTaskLogger(IEventLogService eventLogService) {
this.eventLogService = eventLogService;
}
Expand Down Expand Up @@ -53,6 +52,12 @@ public void HandleEvent(TreeNode node, string eventName)

public void HandleEventAfter(TreeNode node, string eventName)
{
var treeProvider = new TreeProvider();
if (eventName != DocumentEvents.Delete.Name)
{
node = treeProvider.SelectSingleDocument(node.DocumentID, coupledData: true);
}

foreach (var indexName in IndexStore.Instance.GetAll().Select(index => index.IndexName))
{
if (!node.IsIndexedByIndex(indexName))
Expand Down

0 comments on commit e76b712

Please sign in to comment.