Commit 43b04e89 authored by Alish's avatar Alish
Browse files

fix: fixes issue with canceled Orders #1030

parent f1f4ddf9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -20,7 +20,10 @@ export class GeoLocationOrdersResolver {
			geoLocation: IGeoLocation;
			skippedOrderIds: string[];
			options: GeoLocationOrdersOptions;
			searchObj?: { byRegex: Array<{ key: string; value: string }> };
			searchObj?: {
				isCancelled?: boolean;
				byRegex?: Array<{ key: string; value: string }>;
			};
		}
	) {
		const orders = await this.geoLocationsOrdersService.getOrdersForWork(
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ type Query {
}

input SearchOrdersForWork {
	isCancelled: Boolean
	byRegex: [SearchByRegex]
}

+18 −5
Original line number Diff line number Diff line
@@ -151,7 +151,10 @@ export class GeoLocationsOrdersService
		geoLocation: IGeoLocation,
		skippedOrderIds: string[] = [],
		options: GeoLocationOrdersOptions,
		searchObj?: { byRegex: Array<{ key: string; value: string }> }
		searchObj?: {
			isCancelled?: boolean;
			byRegex?: Array<{ key: string; value: string }>;
		}
	): Promise<Order[]> {
		const merchants = await this.geoLocationsWarehousesService.getMerchants(
			geoLocation,
@@ -163,12 +166,22 @@ export class GeoLocationsOrdersService

		let searchByRegex = [];

		if (searchObj && searchObj.byRegex.length > 0) {
			searchByRegex = searchObj.byRegex.map((s) => {
		if (searchObj) {
			const byRegex = searchObj.byRegex;

			if (byRegex && byRegex.length > 0) {
				searchByRegex = byRegex.map((s) => {
					return { [s.key]: { $regex: s.value, $options: 'i' } };
				});
			}

			const isCancelled = searchObj.isCancelled;

			if (isCancelled != null) {
				searchByRegex.push({ isCancelled });
			}
		}

		const orders = await this.ordersService.Model.aggregate([
			{
				$match: _.assign(
+2 −4
Original line number Diff line number Diff line
@@ -121,11 +121,9 @@ export class HomePage {
						.getOrderForWork(
							dbGeoInput,
							carrier.skippedOrderIds,
							null,
							{ sort: 'asc' },
							{
								byRegex: [
									{ key: 'isCancelled', value: 'false' }
								]
								isCancelled: false
							}
						)

+4 −1
Original line number Diff line number Diff line
@@ -13,7 +13,10 @@ export class GeoLocationOrdersService {
		geoLocation: IGeoLocation,
		skippedOrderIds: string[] = [],
		options: { sort: string } = { sort: 'asc' },
		searchObj?: { byRegex: Array<{ key: string; value: string }> }
		searchObj?: {
			isCancelled?: boolean;
			byRegex?: Array<{ key: string; value: string }>;
		}
	) {
		return this.apollo
			.watchQuery<{ getOrderForWork: Order }>({