Add print file analysis fields and fix bug with no inserts (#26)

This commit is contained in:
Niklas Fondberg
2021-09-07 10:20:34 +02:00
committed by GitHub
parent d5945da7ae
commit 4b49c6a93c
3 changed files with 26 additions and 4 deletions
+20 -4
View File
@@ -171,10 +171,11 @@ export class ProductAPI extends BaseSQLDataSource {
): Promise<void> { ): Promise<void> {
return this.knex.raw( return this.knex.raw(
/* sql */ ` /* sql */ `
UPDATE "product-products_fields" SET value = ? INSERT INTO "product-products_fields" (productid, fieldid, value, inserted, updated)
WHERE productid = ? VALUES (?, (SELECT fieldid FROM "product-fields" WHERE field = ?), ?, now(), now())
AND fieldid = (SELECT fieldid FROM "product-fields" WHERE field = ?)`, ON CONFLICT (productid, fieldid)
[value, productId, field], DO UPDATE SET "value" = ?`,
[productId, field, value, value],
); );
} }
@@ -200,6 +201,21 @@ export class ProductAPI extends BaseSQLDataSource {
this.updateProductField(productId, 'name', info.name), this.updateProductField(productId, 'name', info.name),
this.updateProductField(productId, 'batch', info.batch), this.updateProductField(productId, 'batch', info.batch),
this.updateProductField(productId, 'copyright', info.copyright), this.updateProductField(productId, 'copyright', info.copyright),
this.updateProductField(
productId,
'print_file_width',
info.printFileWidth.toString(),
),
this.updateProductField(
productId,
'print_file_height',
info.printFileHeight.toString(),
),
this.updateProductField(
productId,
'print_file_dpi',
info.printFileDpi.toString(),
),
); );
return Promise.all(promises); return Promise.all(promises);
} }
+3
View File
@@ -386,6 +386,9 @@ input ProductInfoInput {
designerId: Int! designerId: Int!
browsable: Boolean! browsable: Boolean!
visible: Boolean! visible: Boolean!
printFileWidth: Int!
printFileHeight: Int!
printFileDpi: Int!
} }
input ProductBlacklistingInput { input ProductBlacklistingInput {
+3
View File
@@ -13,6 +13,9 @@ export interface ProductInfoInput {
designerId: number; designerId: number;
browsable: boolean; browsable: boolean;
visible: boolean; visible: boolean;
printFileWidth: number;
printFileHeight: number;
printFileDpi: number;
} }
export interface ProductBlacklistMarketInput { export interface ProductBlacklistMarketInput {