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:
Niklas Fondberg
2021-09-20 16:11:00 +02:00
committed by GitHub
parent ada116b787
commit 8845dd26d0
3 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ export class ImageServerApi extends RESTDataSource {
async getInteriorsForProduct(
productId: number,
): Promise<Array<{ uri: string }>> {
return this.get(`/rooms/${productId}/`, null, {
return this.get(`/rooms/${productId}/?ts=${Date.now()}`, null, {
cacheOptions: { ttl: 5 },
});
}
+1 -1
View File
@@ -68,7 +68,7 @@ export class InteriorAPI extends BaseSQLDataSource {
`;
const allInteriors = await this.cachedRaw(sql)
.cache(MINUTE * 60)
.cache(60)
.then((data) =>
data.rows.map((row) => {
const res = {
+8
View File
@@ -101,6 +101,14 @@ export const productMutationTypeDefs = {
focusXpoint2,
focusYpoint2,
);
// generate new interiors
const product = await (<ProductAPI>dataSources.productApi).getProduct(
productId,
);
await (<InteriorsLambdaAPI>(
dataSources.interiorsLambdaApi
)).generateNewInteriors(product);
return (<ProductAPI>dataSources.productApi).getProduct(productId);
},
async productBlacklisting(_, { productId, markets }, { dataSources }) {