Loading packages/core/package.json +4 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,9 @@ "dependencies": { "@captemulation/get-parameter-names": "^1.4.2", "@ever-platform/common": "^0.4.3", "@graphql-tools/load-files": "^6.5.1", "@graphql-tools/merge": "^8.1.2", "@graphql-tools/schema": "^8.2.0", "@nestjs/common": "^8.1.1", "@nestjs/core": "^8.1.1", "@nestjs/cqrs": "^8.0.0", Loading Loading @@ -81,9 +84,6 @@ "graphql-playground-middleware-express": "^1.7.22", "graphql-subscriptions": "^1.2.1", "graphql-tools": "^8.2.0", "@graphql-tools/load-files": "^6.5.1", "@graphql-tools/schema": "^8.2.0", "@graphql-tools/merge": "^8.1.2", "handlebars": "^4.7.7", "image-size": "^1.0.0", "install": "^0.13.0", Loading Loading @@ -130,6 +130,7 @@ "symbol-observable": "^4.0.0", "typeorm": "^0.2.38", "typescript-collections": "^1.3.3", "underscore": "^1.13.1", "underscore.string": "^3.3.5", "upath": "^2.0.1", "uuid": "^8.3.2", Loading packages/core/src/services/geo-locations/GeoLocationsProductsService.ts +12 −16 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import { WarehousesService } from '../warehouses'; import Warehouse from '@modules/server.common/entities/Warehouse'; import GeoLocation from '@modules/server.common/entities/GeoLocation'; import ProductInfo from '@modules/server.common/entities/ProductInfo'; import * as _ from 'lodash'; import _, { chain, clone, sortBy } from 'underscore'; import Utils from '@modules/server.common/utils'; import { createEverLogger } from '../../helpers/Log'; import { GeoLocationsWarehousesService } from './GeoLocationsWarehousesService'; Loading @@ -17,8 +17,7 @@ import { } from '@pyro/io'; import IGeoLocationProductsRouter from '@modules/server.common/routers/IGeoLocationProductsRouter'; import IService from '../IService'; import { map, first } from 'rxjs/operators'; import IWarehouseProduct from '@modules/server.common/interfaces/IWarehouseProduct'; import { map } from 'rxjs/operators'; import { IProductTitle, IProductDescription, Loading @@ -26,6 +25,8 @@ 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() @routerName('geo-location-products') Loading Loading @@ -138,27 +139,25 @@ export class GeoLocationsProductsService options?: IGetGeoLocationProductsOptions, searchText?: string ): ProductInfo[] { const underscore_: any = _; // TODO: remove sh..t return underscore_(warehouses) .map((_warehouse) => { const warehouse = _.clone(_warehouse); return chain(warehouses) .map((_warehouse: IWarehouse) => { const warehouse = clone(_warehouse); if (!options || !options.withoutCount) { warehouse.products = warehouse.products.filter( (wProduct) => wProduct.count > 0 (wProduct: IWarehouseProduct) => wProduct.count > 0 ); } if (options) { warehouse.products = warehouse.products.filter((wProduct) => warehouse.products = warehouse.products.filter((wProduct: IWarehouseProduct) => this.productsFilter(wProduct, options) ); } warehouse.products = warehouse.products.filter((wProduct) => warehouse.products = warehouse.products.filter((wProduct: IWarehouseProduct) => this.filterBySearchText(wProduct, searchText) ); return warehouse; }) // remove all warehouse products which count is 0. .map((warehouse) => Loading @@ -176,11 +175,8 @@ export class GeoLocationsProductsService ) .flatten() .groupBy((productInfo) => productInfo.warehouseProduct.productId) .map((productInfos: ProductInfo[], productId) => { return _.minBy( productInfos, (productInfo) => productInfo.distance ); .map((productInfos: ProductInfo[]) => { return sortBy(productInfos, 'distance'); }) .filter((productInfo) => !_.isUndefined(productInfo)) .map((productInfo) => productInfo as ProductInfo) Loading yarn.lock +1 −1 Original line number Diff line number Diff line Loading @@ -35709,7 +35709,7 @@ underscore.string@^3.3.5: sprintf-js "^1.0.3" util-deprecate "^1.0.2" underscore@1.x.x, underscore@^1.8.3, underscore@^1.9.2: underscore@1.x.x, underscore@^1.13.1, underscore@^1.8.3, underscore@^1.9.2: version "1.13.1" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.1.tgz#0c1c6bd2df54b6b69f2314066d65b6cde6fcf9d1" integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g== Loading
packages/core/package.json +4 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,9 @@ "dependencies": { "@captemulation/get-parameter-names": "^1.4.2", "@ever-platform/common": "^0.4.3", "@graphql-tools/load-files": "^6.5.1", "@graphql-tools/merge": "^8.1.2", "@graphql-tools/schema": "^8.2.0", "@nestjs/common": "^8.1.1", "@nestjs/core": "^8.1.1", "@nestjs/cqrs": "^8.0.0", Loading Loading @@ -81,9 +84,6 @@ "graphql-playground-middleware-express": "^1.7.22", "graphql-subscriptions": "^1.2.1", "graphql-tools": "^8.2.0", "@graphql-tools/load-files": "^6.5.1", "@graphql-tools/schema": "^8.2.0", "@graphql-tools/merge": "^8.1.2", "handlebars": "^4.7.7", "image-size": "^1.0.0", "install": "^0.13.0", Loading Loading @@ -130,6 +130,7 @@ "symbol-observable": "^4.0.0", "typeorm": "^0.2.38", "typescript-collections": "^1.3.3", "underscore": "^1.13.1", "underscore.string": "^3.3.5", "upath": "^2.0.1", "uuid": "^8.3.2", Loading
packages/core/src/services/geo-locations/GeoLocationsProductsService.ts +12 −16 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import { WarehousesService } from '../warehouses'; import Warehouse from '@modules/server.common/entities/Warehouse'; import GeoLocation from '@modules/server.common/entities/GeoLocation'; import ProductInfo from '@modules/server.common/entities/ProductInfo'; import * as _ from 'lodash'; import _, { chain, clone, sortBy } from 'underscore'; import Utils from '@modules/server.common/utils'; import { createEverLogger } from '../../helpers/Log'; import { GeoLocationsWarehousesService } from './GeoLocationsWarehousesService'; Loading @@ -17,8 +17,7 @@ import { } from '@pyro/io'; import IGeoLocationProductsRouter from '@modules/server.common/routers/IGeoLocationProductsRouter'; import IService from '../IService'; import { map, first } from 'rxjs/operators'; import IWarehouseProduct from '@modules/server.common/interfaces/IWarehouseProduct'; import { map } from 'rxjs/operators'; import { IProductTitle, IProductDescription, Loading @@ -26,6 +25,8 @@ 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() @routerName('geo-location-products') Loading Loading @@ -138,27 +139,25 @@ export class GeoLocationsProductsService options?: IGetGeoLocationProductsOptions, searchText?: string ): ProductInfo[] { const underscore_: any = _; // TODO: remove sh..t return underscore_(warehouses) .map((_warehouse) => { const warehouse = _.clone(_warehouse); return chain(warehouses) .map((_warehouse: IWarehouse) => { const warehouse = clone(_warehouse); if (!options || !options.withoutCount) { warehouse.products = warehouse.products.filter( (wProduct) => wProduct.count > 0 (wProduct: IWarehouseProduct) => wProduct.count > 0 ); } if (options) { warehouse.products = warehouse.products.filter((wProduct) => warehouse.products = warehouse.products.filter((wProduct: IWarehouseProduct) => this.productsFilter(wProduct, options) ); } warehouse.products = warehouse.products.filter((wProduct) => warehouse.products = warehouse.products.filter((wProduct: IWarehouseProduct) => this.filterBySearchText(wProduct, searchText) ); return warehouse; }) // remove all warehouse products which count is 0. .map((warehouse) => Loading @@ -176,11 +175,8 @@ export class GeoLocationsProductsService ) .flatten() .groupBy((productInfo) => productInfo.warehouseProduct.productId) .map((productInfos: ProductInfo[], productId) => { return _.minBy( productInfos, (productInfo) => productInfo.distance ); .map((productInfos: ProductInfo[]) => { return sortBy(productInfos, 'distance'); }) .filter((productInfo) => !_.isUndefined(productInfo)) .map((productInfo) => productInfo as ProductInfo) Loading
yarn.lock +1 −1 Original line number Diff line number Diff line Loading @@ -35709,7 +35709,7 @@ underscore.string@^3.3.5: sprintf-js "^1.0.3" util-deprecate "^1.0.2" underscore@1.x.x, underscore@^1.8.3, underscore@^1.9.2: underscore@1.x.x, underscore@^1.13.1, underscore@^1.8.3, underscore@^1.9.2: version "1.13.1" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.1.tgz#0c1c6bd2df54b6b69f2314066d65b6cde6fcf9d1" integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==