Generate new interiors on focus point changes and break Cloudfront cache (#50)
* gen-new-interiors-on-focus-changes * Remove 1 hour cache * Cachebreak CDN
This commit is contained in:
@@ -12,7 +12,7 @@ export class ImageServerApi extends RESTDataSource {
|
|||||||
async getInteriorsForProduct(
|
async getInteriorsForProduct(
|
||||||
productId: number,
|
productId: number,
|
||||||
): Promise<Array<{ uri: string }>> {
|
): Promise<Array<{ uri: string }>> {
|
||||||
return this.get(`/rooms/${productId}/`, null, {
|
return this.get(`/rooms/${productId}/?ts=${Date.now()}`, null, {
|
||||||
cacheOptions: { ttl: 5 },
|
cacheOptions: { ttl: 5 },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export class InteriorAPI extends BaseSQLDataSource {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const allInteriors = await this.cachedRaw(sql)
|
const allInteriors = await this.cachedRaw(sql)
|
||||||
.cache(MINUTE * 60)
|
.cache(60)
|
||||||
.then((data) =>
|
.then((data) =>
|
||||||
data.rows.map((row) => {
|
data.rows.map((row) => {
|
||||||
const res = {
|
const res = {
|
||||||
|
|||||||
@@ -101,6 +101,14 @@ export const productMutationTypeDefs = {
|
|||||||
focusXpoint2,
|
focusXpoint2,
|
||||||
focusYpoint2,
|
focusYpoint2,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// generate new interiors
|
||||||
|
const product = await (<ProductAPI>dataSources.productApi).getProduct(
|
||||||
|
productId,
|
||||||
|
);
|
||||||
|
await (<InteriorsLambdaAPI>(
|
||||||
|
dataSources.interiorsLambdaApi
|
||||||
|
)).generateNewInteriors(product);
|
||||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||||
},
|
},
|
||||||
async productBlacklisting(_, { productId, markets }, { dataSources }) {
|
async productBlacklisting(_, { productId, markets }, { dataSources }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user