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:
co-authored by
Arwid Thornström
parent
f73cc8be5f
commit
3f5a1b9169
@@ -11,18 +11,10 @@ export class ImageServerApi extends RESTDataSource {
|
||||
: 'http://images-dev.photowall.com';
|
||||
}
|
||||
|
||||
willSendRequest(request) {
|
||||
request.headers.set('X-Photowall', 'pele');
|
||||
}
|
||||
|
||||
async getInteriorsForProduct(
|
||||
productId: number,
|
||||
type: InteriorType,
|
||||
orientation: Orientation,
|
||||
): Promise<Array<{ uri: string }>> {
|
||||
const it = type.toString().toLowerCase();
|
||||
const or = orientation.toString().toLowerCase();
|
||||
return this.get(`/rooms/${productId}/${or}/${it}/`, null, {
|
||||
return this.get(`/rooms/${productId}/`, null, {
|
||||
cacheOptions: { ttl: 5 },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ export class InteriorAPI extends BaseSQLDataSource {
|
||||
}
|
||||
|
||||
decorateRow(row: any): Interior {
|
||||
console.log('row', row);
|
||||
if (row.roomName) {
|
||||
const parts = row.roomName.split('_');
|
||||
row.roomNumber = this.getInteriorRoomNumber(parts[0]);
|
||||
@@ -86,8 +85,6 @@ export class InteriorAPI extends BaseSQLDataSource {
|
||||
if (filter) {
|
||||
const validUris = await this.imageServerApi.getInteriorsForProduct(
|
||||
filter.productId,
|
||||
filter.type,
|
||||
filter.orientation,
|
||||
);
|
||||
return allInteriors.filter((i: Interior) => {
|
||||
const it = i.type.toString().toLowerCase();
|
||||
|
||||
@@ -64,13 +64,8 @@ type ProductsResult {
|
||||
items: [Product]
|
||||
}
|
||||
|
||||
"""
|
||||
Only return valid interiors for product, type and orientation
|
||||
"""
|
||||
input InteriorsFilterInput {
|
||||
productId: Int!
|
||||
type: InteriorType!
|
||||
orientation: Orientation!
|
||||
}
|
||||
|
||||
type Market {
|
||||
|
||||
@@ -20,8 +20,6 @@ export enum InteriorType {
|
||||
|
||||
export interface InteriorsFilter {
|
||||
productId: number;
|
||||
type: InteriorType;
|
||||
orientation: Orientation;
|
||||
}
|
||||
|
||||
export interface InteriorsFilterInput {
|
||||
|
||||
Reference in New Issue
Block a user