This reverts commit b1da0b547e.
This commit is contained in:
@@ -155,6 +155,7 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
}
|
||||
|
||||
createProductFromRow(row: any) {
|
||||
row.publishingDate = row.publishing_date;
|
||||
row.blacklisting = this.getBlacklisting(row);
|
||||
row.printProducts = this.getPrintProducts(row);
|
||||
row.type = this.getProductTypes(row);
|
||||
@@ -430,6 +431,15 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
promises.push(promise);
|
||||
}
|
||||
|
||||
const pd = info.publishingDate;
|
||||
const publishingDate = new Date(
|
||||
pd.getFullYear(),
|
||||
pd.getMonth(),
|
||||
pd.getDate(),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
promises.push(
|
||||
this.knex
|
||||
.table('product-products')
|
||||
@@ -438,6 +448,7 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
browsable: info.browsable ? 1 : 0,
|
||||
visible: info.visible ? 1 : 0,
|
||||
designerid: info.designerId ?? null,
|
||||
publishingDate: publishingDate,
|
||||
ref1: info.ref1,
|
||||
ref2: info.ref2,
|
||||
ref3: info.ref3,
|
||||
@@ -467,6 +478,32 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function productPublishing
|
||||
* @description updates a products publishing
|
||||
*/
|
||||
async productPublishing(productId: number, date: Date) {
|
||||
return this.knex
|
||||
.table('product-products')
|
||||
.update({
|
||||
publishing_date: date,
|
||||
})
|
||||
.where('productid', productId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function massUpdatePublishingDate
|
||||
* @description Mass update publishing date
|
||||
*/
|
||||
async massUpdatePublishingDate(productIds: Array<number>, date: Date) {
|
||||
return this.knex
|
||||
.table('product-products')
|
||||
.update({
|
||||
publishing_date: date,
|
||||
})
|
||||
.whereIn('productid', productIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function massUpdatePublishing
|
||||
* @description Mass update visible and browsable
|
||||
|
||||
@@ -12,6 +12,7 @@ SELECT products.productid AS id,
|
||||
products.designerid,
|
||||
products.inserted,
|
||||
products.updated,
|
||||
products.publishing_date,
|
||||
products.ref1,
|
||||
products.ref2,
|
||||
products.ref3,
|
||||
@@ -89,7 +90,7 @@ export function products(input: ProductsFilterInput) {
|
||||
AND products.browsable = ${filter?.browsable ? '1' : '0'}`
|
||||
: ``
|
||||
}
|
||||
ORDER BY products.inserted DESC
|
||||
ORDER BY products.publishing_date DESC
|
||||
LIMIT ${limit} OFFSET ${offset}
|
||||
`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user