Remove listprice (#166)
This commit is contained in:
@@ -245,25 +245,6 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
return res.find(Boolean);
|
||||
}
|
||||
|
||||
async getListPrice(
|
||||
printId: number,
|
||||
marketId: number,
|
||||
): Promise<Maybe<number>> {
|
||||
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<Maybe<Product>> {
|
||||
ScopeAccess.validate(this.user).some([
|
||||
Scopes.PRODUCTS_READ,
|
||||
|
||||
@@ -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 = ?';
|
||||
}
|
||||
|
||||
@@ -108,12 +108,6 @@ const PrintProduct = {
|
||||
dataSources.printProductDefaultsApi
|
||||
)).getDefaults(id);
|
||||
},
|
||||
async listprice({ id }, input: MarketInput, { dataSources }) {
|
||||
return (<ProductAPI>dataSources.productApi).getListPrice(
|
||||
id,
|
||||
input.marketId,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
async function getProductsResult(
|
||||
|
||||
@@ -351,7 +351,6 @@ type PrintProduct {
|
||||
updated: DateTime
|
||||
interiors: [Interior]
|
||||
defaults: PrintProductDefaults
|
||||
listprice(marketId: Int!): Float!
|
||||
}
|
||||
|
||||
enum InteriorType {
|
||||
|
||||
Reference in New Issue
Block a user