Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#120
Browse files Browse the repository at this point in the history
  • Loading branch information
Arios67 committed Apr 2, 2022
2 parents 53705e6 + 535380f commit bbecb9d
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 83 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion ars/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.3'
services:
my_backend:
platform: linux/x86_64
image: asia.gcr.io/artiful-a1/my_backend:2.0
image: asia.gcr.io/artiful-a1/my_backend:1.9
build:
context: .
dockerfile: Dockerfile
Expand Down
4 changes: 2 additions & 2 deletions ars/elk/logstash/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ input {
last_run_metadata_path => "./aaa.txt"

tracking_column_type => "numeric"
statement => "select art.id, title, start_price, instant_bid, price, thumbnail, createdAt, deadline, tag1, tag2, tag3, tag4, updatedat, u.nickname, unix_timestamp(art.updatedat) as updatedat from art left join user as u ON art.userId = u.id where unix_timestamp(art.updatedat) > :sql_last_value order by updatedat asc"
statement => "select art.id, title, start_price, instant_bid, thumbnail, createdAt, deadline, is_soldout, tag1, tag2, tag3, tag4, updatedat, u.nickname, unix_timestamp(art.updatedat) as updatedat from art left join user as u ON art.userId = u.id where unix_timestamp(art.updatedat) > :sql_last_value order by updatedat asc"
}
}

output {
elasticsearch {
hosts => "elasticsearch:9200"
index => "artipul09"
index => "artipul00"
}
}
32 changes: 20 additions & 12 deletions ars/src/apis/art/art.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,26 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
from: 0,
size: 500,
query: {
bool: {
must: [{ match: { tag1: tags[0] } }],
},
},
});

if (!result.hits.hits.length) return null;
if (!result.hits.hits.length) return [];

const artTags = result.hits.hits.map((el: any) => {
return {
id: el._source.id,
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
nickname: el._source.nickname,
Expand All @@ -78,24 +80,26 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
from: 0,
size: 500,
query: {
bool: {
must: [{ match: { tag1: tags[0] } }, { match: { tag2: tags[1] } }],
},
},
});

if (!result.hits.hits.length) return null;
if (!result.hits.hits.length) return [];

const artTags = result.hits.hits.map((el: any) => {
return {
id: el._source.id,
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
tag2: el._source.tag2,
Expand All @@ -117,7 +121,9 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
from: 0,
size: 500,
query: {
bool: {
must: [
Expand All @@ -129,16 +135,16 @@ export class ArtResolver {
},
});

if (!result.hits.hits.length) return null;
if (!result.hits.hits.length) return [];

const artTags = result.hits.hits.map((el: any) => {
return {
id: el._source.id,
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
tag2: el._source.tag2,
Expand All @@ -161,7 +167,9 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
from: 0,
size: 500,
query: {
bool: {
must: [
Expand All @@ -174,16 +182,16 @@ export class ArtResolver {
},
});

if (!result.hits.hits.length) return null;
if (!result.hits.hits.length) return [];

const artTags = result.hits.hits.map((el: any) => {
return {
id: el._source.id,
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
tag2: el._source.tag2,
Expand Down
41 changes: 16 additions & 25 deletions ars/src/apis/art/art.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ export class ArtService {
tag2: tags[1],
tag3: tags[2],
tag4: tags[3],
createdAt: MoreThan(createdAt),
},
order: { createdAt: 'ASC' },
});
break;
case 3:
Expand All @@ -45,28 +43,22 @@ export class ArtService {
tag1: tags[0],
tag2: tags[1],
tag3: tags[2],
createdAt: MoreThan(createdAt),
},
order: { createdAt: 'ASC' },
});
break;
case 2:
result = await this.artRepository.find({
where: {
tag1: tags[0],
tag2: tags[1],
createdAt: MoreThan(createdAt),
},
order: { createdAt: 'ASC' },
});
break;
case 1:
result = await this.artRepository.find({
where: {
tag1: tags[0],
createdAt: MoreThan(createdAt),
},
order: { createdAt: 'ASC' },
});
}
await queryRunner.commitTransaction();
Expand Down Expand Up @@ -105,7 +97,6 @@ export class ArtService {
skip: 10 * (page - 1),
where: { user: currentUser.id, deletedAt: Not(IsNull()) },
});
console.log(art);
return art;
}

Expand Down Expand Up @@ -134,35 +125,35 @@ export class ArtService {
}

// 작품 등록
async create({ image_urls, tags, ...rest }, currentUser) {
async create({ thumbnail, tags, ...rest }, currentUser) {
const queryRunner = this.connection.createQueryRunner();
await queryRunner.connect();
await queryRunner.startTransaction();
try {
const result = await queryRunner.manager.save(Art, {
...rest,
user: currentUser,
thumbnail: image_urls[0],
thumbnail: thumbnail,
tag1: tags[0],
tag2: tags[1],
tag3: tags[2],
tag4: tags[3],
});

for (let i = 0; i < image_urls.length; i++) {
if (i === 0) {
await queryRunner.manager.save(ArtImage, {
url: image_urls[i],
isMain: true,
art: result,
});
} else {
await queryRunner.manager.save(ArtImage, {
url: image_urls[i],
art: result,
});
}
}
// for (let i = 0; i < image_urls.length; i++) {
// if (i === 0) {
// await queryRunner.manager.save(ArtImage, {
// url: image_urls[i],
// isMain: true,
// art: result,
// });
// } else {
// await queryRunner.manager.save(ArtImage, {
// url: image_urls[i],
// art: result,
// });
// }
// }
await queryRunner.commitTransaction();
return result;
} catch (error) {
Expand Down
21 changes: 6 additions & 15 deletions ars/src/apis/art/dto/createArtInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,18 @@ export class CreateArtInput {
@Field(() => Int)
price: number;

@Field(() => Date)
@Field(() => Date, { nullable: true })
deadline: Date;

@Field(() => [String])
image_urls: string[];
// @Field(() => [String])
// image_urls: string[];

@Field(() => String)
thumbnail: string;

@Field(() => Boolean)
is_soldout: boolean;

@Field(() => [String])
tags: string[];

// @Field(() => String)
// tag1: string;

// @Field(() => String, { nullable: true })
// tag2?: string;

// @Field(() => String, { nullable: true })
// tag3?: string;

// @Field(() => String, { nullable: true })
// tag4?: string;
}
4 changes: 2 additions & 2 deletions ars/src/apis/art/entities/art.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class Art {
deletedAt: Date;

@Column()
@Field(() => Date)
deadline: Date;
@Field(() => String)
deadline: string;

@Column({ default: false })
@Field(() => Boolean)
Expand Down
12 changes: 6 additions & 6 deletions ars/src/apis/art/entities/artsSearch.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ export class ArtsSearch {
@Field(() => Int)
instant_bid: number;

@Column({ default: null })
@Field(() => Int)
price: number;

@Column()
@Field(() => String)
thumbnail: string;

@Column()
@Field(() => Date)
deadline: Date;
@Field(() => String, { nullable: true })
deadline: string;

@Column({ default: false })
@Field(() => Boolean)
is_soldout: boolean;

@Column()
@Field(() => String)
Expand Down
1 change: 1 addition & 0 deletions ars/src/apis/art/entities/likeArt.entity.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { Field, ObjectType } from '@nestjs/graphql';
import { User } from 'src/apis/user/entities/user.entity';
import {
Expand Down
1 change: 1 addition & 0 deletions ars/src/apis/board/board.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class BoardService {
const user = await queryRunner.manager.findOne(User, {
id: currentUser.id,
});

const result = await queryRunner.manager.save(Board, {
...rest,
user: user,
Expand Down
2 changes: 1 addition & 1 deletion ars/src/apis/board/entities/board.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Board {
@Field(() => String)
thumbnail: string;

@ManyToOne(() => User)
@ManyToOne(() => User, { eager: true })
@Field(() => User)
user: User;
}
14 changes: 0 additions & 14 deletions ars/src/apis/tag/entities/tag.entity.ts

This file was deleted.

10 changes: 5 additions & 5 deletions ars/src/common/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Art {
thumbnail: String!
createdAt: DateTime!
deletedAt: DateTime!
deadline: DateTime!
deadline: String!
is_soldout: Boolean!
updatedAt: DateTime!
user: User!
Expand Down Expand Up @@ -101,9 +101,9 @@ type ArtsSearch {
title: String!
start_price: Int!
instant_bid: Int!
price: Int!
thumbnail: String!
deadline: DateTime!
deadline: String
is_soldout: Boolean!
tag1: String!
tag2: String
tag3: String
Expand Down Expand Up @@ -203,8 +203,8 @@ input CreateArtInput {
start_price: Int!
instant_bid: Int!
price: Int!
deadline: DateTime!
image_urls: [String!]!
deadline: DateTime
thumbnail: String!
is_soldout: Boolean!
tags: [String!]!
}
Expand Down

0 comments on commit bbecb9d

Please sign in to comment.