Loading packages/core/src/services/geo-locations/GeoLocationsProductsService.ts +5 −12 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import { } from '@modules/server.common/interfaces/IProduct'; import WarehouseProduct from '@modules/server.common/entities/WarehouseProduct'; import { IGetGeoLocationProductsOptions } from 'graphql/geo-locations/geo-location.resolver'; import IWarehouse from '@ever-platform/common/src/interfaces/IWarehouse'; import IWarehouseProduct from '@ever-platform/common/src/interfaces/IWarehouseProduct'; @injectable() Loading Loading @@ -122,14 +121,12 @@ export class GeoLocationsProductsService merchantsIds: options ? options.merchantIds : null, } ); const products = this._getProductsFromWarehouses( geoLocation, merchants.map((m) => new Warehouse(m)), options, searchText ); return products.slice(pagingOptions.skip).slice(0, pagingOptions.limit); } Loading @@ -140,30 +137,27 @@ export class GeoLocationsProductsService searchText?: string ): ProductInfo[] { return chain(warehouses) .map((_warehouse: IWarehouse) => { .map((_warehouse: Warehouse) => { const warehouse = clone(_warehouse); if (!options || !options.withoutCount) { warehouse.products = warehouse.products.filter( (wProduct: IWarehouseProduct) => wProduct.count > 0 ); } if (options) { warehouse.products = warehouse.products.filter((wProduct: IWarehouseProduct) => this.productsFilter(wProduct, options) ); } warehouse.products = warehouse.products.filter((wProduct: IWarehouseProduct) => this.filterBySearchText(wProduct, searchText) ); return warehouse; }) // remove all warehouse products which count is 0. .map((warehouse) => .map((warehouse: Warehouse) => _.map(warehouse.products, (warehouseProduct) => { return new ProductInfo({ warehouseId: warehouse.id, warehouseId: warehouse._id.toString(), warehouseLogo: warehouse.logo, warehouseProduct, distance: Utils.getDistance( Loading @@ -175,11 +169,10 @@ export class GeoLocationsProductsService ) .flatten() .groupBy((productInfo) => productInfo.warehouseProduct.productId) .map((productInfos: ProductInfo[]) => { return sortBy(productInfos, 'distance'); }) .filter((productInfo) => !_.isUndefined(productInfo)) .map((productInfos: ProductInfo[]) => sortBy(productInfos, 'distance')) .map((productInfo) => productInfo as ProductInfo) .flatten() .value(); } Loading Loading
packages/core/src/services/geo-locations/GeoLocationsProductsService.ts +5 −12 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import { } from '@modules/server.common/interfaces/IProduct'; import WarehouseProduct from '@modules/server.common/entities/WarehouseProduct'; import { IGetGeoLocationProductsOptions } from 'graphql/geo-locations/geo-location.resolver'; import IWarehouse from '@ever-platform/common/src/interfaces/IWarehouse'; import IWarehouseProduct from '@ever-platform/common/src/interfaces/IWarehouseProduct'; @injectable() Loading Loading @@ -122,14 +121,12 @@ export class GeoLocationsProductsService merchantsIds: options ? options.merchantIds : null, } ); const products = this._getProductsFromWarehouses( geoLocation, merchants.map((m) => new Warehouse(m)), options, searchText ); return products.slice(pagingOptions.skip).slice(0, pagingOptions.limit); } Loading @@ -140,30 +137,27 @@ export class GeoLocationsProductsService searchText?: string ): ProductInfo[] { return chain(warehouses) .map((_warehouse: IWarehouse) => { .map((_warehouse: Warehouse) => { const warehouse = clone(_warehouse); if (!options || !options.withoutCount) { warehouse.products = warehouse.products.filter( (wProduct: IWarehouseProduct) => wProduct.count > 0 ); } if (options) { warehouse.products = warehouse.products.filter((wProduct: IWarehouseProduct) => this.productsFilter(wProduct, options) ); } warehouse.products = warehouse.products.filter((wProduct: IWarehouseProduct) => this.filterBySearchText(wProduct, searchText) ); return warehouse; }) // remove all warehouse products which count is 0. .map((warehouse) => .map((warehouse: Warehouse) => _.map(warehouse.products, (warehouseProduct) => { return new ProductInfo({ warehouseId: warehouse.id, warehouseId: warehouse._id.toString(), warehouseLogo: warehouse.logo, warehouseProduct, distance: Utils.getDistance( Loading @@ -175,11 +169,10 @@ export class GeoLocationsProductsService ) .flatten() .groupBy((productInfo) => productInfo.warehouseProduct.productId) .map((productInfos: ProductInfo[]) => { return sortBy(productInfos, 'distance'); }) .filter((productInfo) => !_.isUndefined(productInfo)) .map((productInfos: ProductInfo[]) => sortBy(productInfos, 'distance')) .map((productInfo) => productInfo as ProductInfo) .flatten() .value(); } Loading