Add publishing date (#107)
This commit is contained in:
@@ -8,6 +8,7 @@ COPY . app/
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
# Set node env
|
# Set node env
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
ENV NEW_RELIC_NO_CONFIG_FILE=true
|
||||||
# Installs npm dependencies on container
|
# Installs npm dependencies on container
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
# Command container will actually run when called
|
# Command container will actually run when called
|
||||||
|
|||||||
+3466
-3436
File diff suppressed because it is too large
Load Diff
@@ -155,6 +155,7 @@ export class ProductAPI extends BaseSQLDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createProductFromRow(row: any) {
|
createProductFromRow(row: any) {
|
||||||
|
row.publishingDate = row.publishing_date;
|
||||||
row.blacklisting = this.getBlacklisting(row);
|
row.blacklisting = this.getBlacklisting(row);
|
||||||
row.printProducts = this.getPrintProducts(row);
|
row.printProducts = this.getPrintProducts(row);
|
||||||
row.type = this.getProductTypes(row);
|
row.type = this.getProductTypes(row);
|
||||||
@@ -430,6 +431,15 @@ export class ProductAPI extends BaseSQLDataSource {
|
|||||||
promises.push(promise);
|
promises.push(promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pd = info.publishingDate;
|
||||||
|
const publishingDate = new Date(
|
||||||
|
pd.getFullYear(),
|
||||||
|
pd.getMonth(),
|
||||||
|
pd.getDate(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
);
|
||||||
promises.push(
|
promises.push(
|
||||||
this.knex
|
this.knex
|
||||||
.table('product-products')
|
.table('product-products')
|
||||||
@@ -438,6 +448,7 @@ export class ProductAPI extends BaseSQLDataSource {
|
|||||||
browsable: info.browsable ? 1 : 0,
|
browsable: info.browsable ? 1 : 0,
|
||||||
visible: info.visible ? 1 : 0,
|
visible: info.visible ? 1 : 0,
|
||||||
designerid: info.designerId ?? null,
|
designerid: info.designerId ?? null,
|
||||||
|
publishingDate: publishingDate,
|
||||||
ref1: info.ref1,
|
ref1: info.ref1,
|
||||||
ref2: info.ref2,
|
ref2: info.ref2,
|
||||||
ref3: info.ref3,
|
ref3: info.ref3,
|
||||||
@@ -467,6 +478,32 @@ export class ProductAPI extends BaseSQLDataSource {
|
|||||||
return Promise.all(promises);
|
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
|
* @function massUpdatePublishing
|
||||||
* @description Mass update visible and browsable
|
* @description Mass update visible and browsable
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ SELECT products.productid AS id,
|
|||||||
products.designerid,
|
products.designerid,
|
||||||
products.inserted,
|
products.inserted,
|
||||||
products.updated,
|
products.updated,
|
||||||
|
products.publishing_date,
|
||||||
products.ref1,
|
products.ref1,
|
||||||
products.ref2,
|
products.ref2,
|
||||||
products.ref3,
|
products.ref3,
|
||||||
@@ -89,7 +90,7 @@ export function products(input: ProductsFilterInput) {
|
|||||||
AND products.browsable = ${filter?.browsable ? '1' : '0'}`
|
AND products.browsable = ${filter?.browsable ? '1' : '0'}`
|
||||||
: ``
|
: ``
|
||||||
}
|
}
|
||||||
ORDER BY products.inserted DESC
|
ORDER BY products.publishing_date DESC
|
||||||
LIMIT ${limit} OFFSET ${offset}
|
LIMIT ${limit} OFFSET ${offset}
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|||||||
+11
-1
@@ -1,4 +1,4 @@
|
|||||||
require('newrelic');
|
const newrelic = require('newrelic');
|
||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@@ -90,6 +90,7 @@ const context = async ({ req }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
try {
|
||||||
const server = new ApolloServer({
|
const server = new ApolloServer({
|
||||||
typeDefs,
|
typeDefs,
|
||||||
resolvers,
|
resolvers,
|
||||||
@@ -97,6 +98,11 @@ async function main() {
|
|||||||
context,
|
context,
|
||||||
introspection: true,
|
introspection: true,
|
||||||
plugins: [newRelicPlugin],
|
plugins: [newRelicPlugin],
|
||||||
|
formatError: (err) => {
|
||||||
|
console.log('Error (fmt):', err);
|
||||||
|
newrelic.noticeError(err);
|
||||||
|
return err;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await server.listen();
|
await server.listen();
|
||||||
@@ -105,5 +111,9 @@ async function main() {
|
|||||||
'Server is running on http://localhost:4000, ',
|
'Server is running on http://localhost:4000, ',
|
||||||
process.env.ENVIRONMENT_NAME,
|
process.env.ENVIRONMENT_NAME,
|
||||||
);
|
);
|
||||||
|
} catch (ex) {
|
||||||
|
newrelic.noticeError(ex);
|
||||||
|
console.error('Got terminal exception:', ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
main();
|
main();
|
||||||
|
|||||||
@@ -476,4 +476,22 @@ export const productMutationTypeDefs = {
|
|||||||
value: 'OK',
|
value: 'OK',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @function massUpdatePublishing
|
||||||
|
* @description Mutate the Publishing for products
|
||||||
|
*/
|
||||||
|
async massUpdatePublishingDate(
|
||||||
|
_,
|
||||||
|
{ productIds, date },
|
||||||
|
{ dataSources, auth },
|
||||||
|
) {
|
||||||
|
checkAccess(['products.write'], auth);
|
||||||
|
await (<ProductAPI>dataSources.productApi).massUpdatePublishingDate(
|
||||||
|
productIds,
|
||||||
|
date,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
value: 'OK',
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+27
-10
@@ -236,6 +236,7 @@ type Product {
|
|||||||
browsable: Boolean!
|
browsable: Boolean!
|
||||||
inserted: DateTime!
|
inserted: DateTime!
|
||||||
updated: DateTime
|
updated: DateTime
|
||||||
|
publishingDate: DateTime!
|
||||||
printProducts: [PrintProduct]
|
printProducts: [PrintProduct]
|
||||||
blacklisting: [ProductBlacklist]
|
blacklisting: [ProductBlacklist]
|
||||||
categories: [Category]
|
categories: [Category]
|
||||||
@@ -405,6 +406,7 @@ input ProductInfoInput {
|
|||||||
designerId: Int
|
designerId: Int
|
||||||
browsable: Boolean!
|
browsable: Boolean!
|
||||||
visible: Boolean!
|
visible: Boolean!
|
||||||
|
publishingDate: DateTime!
|
||||||
printFileWidth: Int!
|
printFileWidth: Int!
|
||||||
printFileHeight: Int!
|
printFileHeight: Int!
|
||||||
printFileDpi: Int!
|
printFileDpi: Int!
|
||||||
@@ -435,8 +437,9 @@ type IdNumberResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
|
"""
|
||||||
""" Product """
|
Product
|
||||||
|
"""
|
||||||
addProduct(name: String!, batch: String): Product
|
addProduct(name: String!, batch: String): Product
|
||||||
productInfo(productId: Int!, info: ProductInfoInput!): Product
|
productInfo(productId: Int!, info: ProductInfoInput!): Product
|
||||||
productWallpaperType(
|
productWallpaperType(
|
||||||
@@ -447,8 +450,9 @@ type Mutation {
|
|||||||
productId: Int!
|
productId: Int!
|
||||||
markets: [ProductBlacklistingInput]
|
markets: [ProductBlacklistingInput]
|
||||||
): Product
|
): Product
|
||||||
|
"""
|
||||||
""" Product Image """
|
Product Image
|
||||||
|
"""
|
||||||
productFocusPoint(
|
productFocusPoint(
|
||||||
productId: Int!
|
productId: Int!
|
||||||
focusXpoint2: Float!
|
focusXpoint2: Float!
|
||||||
@@ -465,22 +469,32 @@ type Mutation {
|
|||||||
height: Int!
|
height: Int!
|
||||||
): String
|
): String
|
||||||
|
|
||||||
""" Product Relations """
|
"""
|
||||||
|
Product Relations
|
||||||
|
"""
|
||||||
addRelatedProducts(productId: Int!, articleNumbers: [String]!): Product
|
addRelatedProducts(productId: Int!, articleNumbers: [String]!): Product
|
||||||
removeRelatedProducts(productId: Int!, relatedProductIds: [Int]!): Product
|
removeRelatedProducts(productId: Int!, relatedProductIds: [Int]!): Product
|
||||||
|
|
||||||
""" Product Categories """
|
"""
|
||||||
|
Product Categories
|
||||||
|
"""
|
||||||
addCategoriesToProduct(productId: Int!, categoryIds: [Int]!): Product
|
addCategoriesToProduct(productId: Int!, categoryIds: [Int]!): Product
|
||||||
removeCategoriesFromProduct(productId: Int!, categoryIds: [Int]!): Product
|
removeCategoriesFromProduct(productId: Int!, categoryIds: [Int]!): Product
|
||||||
|
|
||||||
""" Product Keywords """
|
"""
|
||||||
|
Product Keywords
|
||||||
|
"""
|
||||||
productKeywords(productId: Int!, keywordIds: [Int]): Product
|
productKeywords(productId: Int!, keywordIds: [Int]): Product
|
||||||
addKeyword(name: String!, type: KeywordType): Keyword
|
addKeyword(name: String!, type: KeywordType): Keyword
|
||||||
|
|
||||||
""" Product Other """
|
"""
|
||||||
|
Product Other
|
||||||
|
"""
|
||||||
updateProductComments(productId: Int!, comments: String!): Product
|
updateProductComments(productId: Int!, comments: String!): Product
|
||||||
|
|
||||||
""" Printproducts """
|
"""
|
||||||
|
Printproducts
|
||||||
|
"""
|
||||||
productGroup(productId: Int!, groupIds: [Int]): Product
|
productGroup(productId: Int!, groupIds: [Int]): Product
|
||||||
productGroupInteriors(productId: Int!, groupId: Int!, uris: [String]): Product
|
productGroupInteriors(productId: Int!, groupId: Int!, uris: [String]): Product
|
||||||
addOwnInteriorToPrintProduct(
|
addOwnInteriorToPrintProduct(
|
||||||
@@ -496,7 +510,9 @@ type Mutation {
|
|||||||
border: BorderType!
|
border: BorderType!
|
||||||
): PrintProductDefaults
|
): PrintProductDefaults
|
||||||
|
|
||||||
""" Mass Update """
|
"""
|
||||||
|
Mass Update
|
||||||
|
"""
|
||||||
massUpdatePublishing(
|
massUpdatePublishing(
|
||||||
productIds: [Int]!
|
productIds: [Int]!
|
||||||
visible: Boolean
|
visible: Boolean
|
||||||
@@ -506,4 +522,5 @@ type Mutation {
|
|||||||
productIds: [Int]!
|
productIds: [Int]!
|
||||||
markets: [ProductBlacklistingInput]
|
markets: [ProductBlacklistingInput]
|
||||||
): StringResult
|
): StringResult
|
||||||
|
massUpdatePublishingDate(productIds: [Int]!, date: DateTime!): StringResult
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export interface ProductInfoInput {
|
|||||||
designerId: Maybe<number>;
|
designerId: Maybe<number>;
|
||||||
browsable: boolean;
|
browsable: boolean;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
publishingDate: Date;
|
||||||
printFileWidth: number;
|
printFileWidth: number;
|
||||||
printFileHeight: number;
|
printFileHeight: number;
|
||||||
printFileDpi: number;
|
printFileDpi: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user