Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(default-search-plugin, elasticsearch-plugin) Adding StockMovement… #3113

Open
wants to merge 3 commits into
base: minor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions license/signatures/version1/cla.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@
"created_at": "2024-09-30T12:27:50Z",
"repoId": 136938012,
"pullRequestNo": 3096
},
{
"name": "kyunal",
"id": 33372279,
"comment_id": 2395056311,
"created_at": "2024-10-05T13:21:30Z",
"repoId": 136938012,
"pullRequestNo": 3110
},
{
"name": "LeftoversTodayAppAdmin",
"id": 139936478,
"comment_id": 2395622489,
"created_at": "2024-10-06T23:06:02Z",
"repoId": 136938012,
"pullRequestNo": 3112
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { JobQueueService } from '../../job-queue/job-queue.service';
import { PluginCommonModule } from '../plugin-common.module';
import { VendurePlugin } from '../vendure-plugin';

import { StockMovementEvent } from '../../event-bus/events/stock-movement-event';
import { stockStatusExtension } from './api/api-extensions';
import { AdminFulltextSearchResolver, ShopFulltextSearchResolver } from './api/fulltext-search.resolver';
import { BUFFER_SEARCH_INDEX_UPDATES, PLUGIN_INIT_OPTIONS } from './constants';
Expand Down Expand Up @@ -166,6 +167,13 @@ export class DefaultSearchPlugin implements OnApplicationBootstrap, OnApplicatio
}
});

this.eventBus.ofType(StockMovementEvent).subscribe(event => {
return this.searchIndexService.updateVariants(
event.ctx,
event.stockMovements.map(m => m.productVariant),
);
});

// TODO: Remove this buffering logic because because we have dedicated buffering based on #1137
const collectionModification$ = this.eventBus.ofType(CollectionModificationEvent);
const closingNotifier$ = collectionModification$.pipe(debounceTime(50));
Expand Down
8 changes: 8 additions & 0 deletions packages/elasticsearch-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ProductVariantChannelEvent,
ProductVariantEvent,
SearchJobBufferService,
StockMovementEvent,
TaxRateModificationEvent,
Type,
VendurePlugin,
Expand Down Expand Up @@ -349,6 +350,13 @@ export class ElasticsearchPlugin implements OnApplicationBootstrap {
}
});

this.eventBus.ofType(StockMovementEvent).subscribe(event => {
return this.elasticsearchIndexService.updateVariants(
event.ctx,
event.stockMovements.map(m => m.productVariant),
);
});

// TODO: Remove this buffering logic because because we have dedicated buffering based on #1137
const collectionModification$ = this.eventBus.ofType(CollectionModificationEvent);
const closingNotifier$ = collectionModification$.pipe(debounceTime(50));
Expand Down
Loading