Skip to content

Commit

Permalink
Merge pull request #117 from Daseul1/feat/#116
Browse files Browse the repository at this point in the history
[#116]feat: 엘라스틱 최종 수정3
  • Loading branch information
Daseul1 committed Apr 2, 2022
2 parents 3c0182b + 06faf74 commit 1aea584
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 31 deletions.
Binary file modified .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion ars/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ version: '3.3'

services:
my_backend:
platform: linux/x86_64
image: asia.gcr.io/artiful-a1/my_backend:1.9
build:
context: .
dockerfile: Dockerfile
env_file:
- ./.env.dev
ports:
- 3000:3000
volumes:
- ./src:/myfolder/src
- ./.env:/myfolder/.env

my_database:
platform: linux/x86_64
Expand Down
2 changes: 1 addition & 1 deletion ars/elk/logstash/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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, 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"
}
}

Expand Down
13 changes: 9 additions & 4 deletions ars/src/apis/art/art.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class ArtResolver {

const result = await this.elasticsearchService.search({
index: 'artipul09',
from: 0,
size: 500,
query: {
bool: {
must: [{ match: { tag1: tags[0] } }],
Expand All @@ -56,7 +58,6 @@ export class ArtResolver {
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
Expand All @@ -79,6 +80,8 @@ export class ArtResolver {

const result = await this.elasticsearchService.search({
index: 'artipul09',
from: 0,
size: 500,
query: {
bool: {
must: [{ match: { tag1: tags[0] } }, { match: { tag2: tags[1] } }],
Expand All @@ -94,7 +97,6 @@ export class ArtResolver {
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
Expand All @@ -118,6 +120,8 @@ export class ArtResolver {

const result = await this.elasticsearchService.search({
index: 'artipul09',
from: 0,
size: 500,
query: {
bool: {
must: [
Expand All @@ -132,12 +136,12 @@ export class ArtResolver {
if (!result.hits.hits.length) return null;

const artTags = result.hits.hits.map((el: any) => {
console.log('=======', el);
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,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
Expand All @@ -162,6 +166,8 @@ export class ArtResolver {

const result = await this.elasticsearchService.search({
index: 'artipul09',
from: 0,
size: 500,
query: {
bool: {
must: [
Expand All @@ -182,7 +188,6 @@ export class ArtResolver {
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
Expand Down
8 changes: 0 additions & 8 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
14 changes: 1 addition & 13 deletions ars/src/apis/art/dto/createArtInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class CreateArtInput {
@Field(() => Int)
price: number;

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

@Field(() => [String])
Expand All @@ -28,16 +28,4 @@ export class CreateArtInput {

@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/artsSearch.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export class ArtsSearch {
thumbnail: string;

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

@Column()
@Field(() => String)
Expand Down
1 change: 1 addition & 0 deletions ars/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { PaymentModule } from './apis/payment/payment.module';
entities: [__dirname + '/apis/**/*.entity.*'],
synchronize: true,
logging: true,
timezone: 'Asia/seoul',
}),
CacheModule.register<RedisClientOptions>({
store: redisStore,
Expand Down
4 changes: 2 additions & 2 deletions ars/src/common/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type ArtsSearch {
instant_bid: Int!
price: Int!
thumbnail: String!
deadline: DateTime!
deadline: String
tag1: String!
tag2: String
tag3: String
Expand Down Expand Up @@ -203,7 +203,7 @@ input CreateArtInput {
start_price: Int!
instant_bid: Int!
price: Int!
deadline: DateTime!
deadline: DateTime
image_urls: [String!]!
is_soldout: Boolean!
tags: [String!]!
Expand Down

0 comments on commit 1aea584

Please sign in to comment.