Simplify interiors api for product (#33)

* Simplify interiors api for product

* removed console

Co-authored-by: Arwid Thornström <arwidt@gmail.com>
This commit is contained in:
Niklas Fondberg
2021-09-07 15:38:03 +02:00
committed by GitHub
co-authored by Arwid Thornström
parent f73cc8be5f
commit 3f5a1b9169
4 changed files with 1 additions and 19 deletions
+1 -9
View File
@@ -11,18 +11,10 @@ export class ImageServerApi extends RESTDataSource {
: 'http://images-dev.photowall.com'; : 'http://images-dev.photowall.com';
} }
willSendRequest(request) {
request.headers.set('X-Photowall', 'pele');
}
async getInteriorsForProduct( async getInteriorsForProduct(
productId: number, productId: number,
type: InteriorType,
orientation: Orientation,
): Promise<Array<{ uri: string }>> { ): Promise<Array<{ uri: string }>> {
const it = type.toString().toLowerCase(); return this.get(`/rooms/${productId}/`, null, {
const or = orientation.toString().toLowerCase();
return this.get(`/rooms/${productId}/${or}/${it}/`, null, {
cacheOptions: { ttl: 5 }, cacheOptions: { ttl: 5 },
}); });
} }
-3
View File
@@ -51,7 +51,6 @@ export class InteriorAPI extends BaseSQLDataSource {
} }
decorateRow(row: any): Interior { decorateRow(row: any): Interior {
console.log('row', row);
if (row.roomName) { if (row.roomName) {
const parts = row.roomName.split('_'); const parts = row.roomName.split('_');
row.roomNumber = this.getInteriorRoomNumber(parts[0]); row.roomNumber = this.getInteriorRoomNumber(parts[0]);
@@ -86,8 +85,6 @@ export class InteriorAPI extends BaseSQLDataSource {
if (filter) { if (filter) {
const validUris = await this.imageServerApi.getInteriorsForProduct( const validUris = await this.imageServerApi.getInteriorsForProduct(
filter.productId, filter.productId,
filter.type,
filter.orientation,
); );
return allInteriors.filter((i: Interior) => { return allInteriors.filter((i: Interior) => {
const it = i.type.toString().toLowerCase(); const it = i.type.toString().toLowerCase();
-5
View File
@@ -64,13 +64,8 @@ type ProductsResult {
items: [Product] items: [Product]
} }
"""
Only return valid interiors for product, type and orientation
"""
input InteriorsFilterInput { input InteriorsFilterInput {
productId: Int! productId: Int!
type: InteriorType!
orientation: Orientation!
} }
type Market { type Market {
-2
View File
@@ -20,8 +20,6 @@ export enum InteriorType {
export interface InteriorsFilter { export interface InteriorsFilter {
productId: number; productId: number;
type: InteriorType;
orientation: Orientation;
} }
export interface InteriorsFilterInput { export interface InteriorsFilterInput {