From 3101e04b661a96d854bcd41dd6f16a188a9580f5 Mon Sep 17 00:00:00 2001 From: Anders Gustafsson <34234789+anders-photowall@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:49:48 +0200 Subject: [PATCH] Remove listprice (#166) --- src/datasources/product-api.ts | 19 ------------------- src/datasources/sql/products-sql.ts | 16 ---------------- src/resolvers/products-resolver.ts | 6 ------ src/schema.graphql | 1 - 4 files changed, 42 deletions(-) diff --git a/src/datasources/product-api.ts b/src/datasources/product-api.ts index b1b37d3..e241766 100644 --- a/src/datasources/product-api.ts +++ b/src/datasources/product-api.ts @@ -245,25 +245,6 @@ export class ProductAPI extends BaseSQLDataSource { return res.find(Boolean); } - async getListPrice( - printId: number, - marketId: number, - ): Promise> { - ScopeAccess.validate(this.user).some([ - Scopes.PRODUCTS_READ, - Scopes.PRODUCTS_PUBLIC_READ, - ]); - const query = sql.getProductListPrice(); - try { - const res = await this.knex.raw(query, [marketId, printId]); - return res.rows[0].listprice; - } catch (error) { - throw new GraphQLError('No listprice found', { - extensions: { code: ApolloServerErrorCode.BAD_USER_INPUT }, - }); - } - } - async getProductByPath(path: string): Promise> { ScopeAccess.validate(this.user).some([ Scopes.PRODUCTS_READ, diff --git a/src/datasources/sql/products-sql.ts b/src/datasources/sql/products-sql.ts index 50b7849..1a29950 100644 --- a/src/datasources/sql/products-sql.ts +++ b/src/datasources/sql/products-sql.ts @@ -223,19 +223,3 @@ export function searchByFieldValue(fieldid: number) { ` ); } - -export function getProductListPrice() { - // Temporary solution during partial release of new pricing system. - // Wallpapers read price from new pricing system's listprice view, external products use the old view. - return ` - SELECT CASE - WHEN groupid IN (1,3) THEN new.listprice - ELSE old.listprice - END AS listprice - FROM v_listprices_new new - JOIN "product-printproducts" pp ON new.printproduct_id = printid - JOIN v_listprices old USING (market_id, printproduct_id) - WHERE new.market_id = ? AND new.printproduct_id = ? - `; - // return 'SELECT listprice FROM v_listprices WHERE market_id = ? AND printproduct_id = ?'; -} diff --git a/src/resolvers/products-resolver.ts b/src/resolvers/products-resolver.ts index e61f090..552035b 100644 --- a/src/resolvers/products-resolver.ts +++ b/src/resolvers/products-resolver.ts @@ -108,12 +108,6 @@ const PrintProduct = { dataSources.printProductDefaultsApi )).getDefaults(id); }, - async listprice({ id }, input: MarketInput, { dataSources }) { - return (dataSources.productApi).getListPrice( - id, - input.marketId, - ); - }, }; async function getProductsResult( diff --git a/src/schema.graphql b/src/schema.graphql index b51795c..4bf40c9 100644 --- a/src/schema.graphql +++ b/src/schema.graphql @@ -351,7 +351,6 @@ type PrintProduct { updated: DateTime interiors: [Interior] defaults: PrintProductDefaults - listprice(marketId: Int!): Float! } enum InteriorType {