-
Notifications
You must be signed in to change notification settings - Fork 0
feat(search): 가격 분포 facets(searchProductFacets) #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/features/product/dto/inputs/search-product-facets.input.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { IsArray, IsNotEmpty, IsOptional, IsString } from 'class-validator'; | ||
|
|
||
| export class SearchProductFacetsInput { | ||
| @IsString() | ||
| keyword!: string; | ||
|
|
||
| @IsOptional() | ||
| @IsArray() | ||
| @IsString({ each: true }) | ||
| @IsNotEmpty({ each: true }) | ||
| eventCategoryIds?: string[]; | ||
|
|
||
| @IsOptional() | ||
| @IsArray() | ||
| @IsString({ each: true }) | ||
| @IsNotEmpty({ each: true }) | ||
| styleCategoryIds?: string[]; | ||
|
|
||
| @IsOptional() | ||
| @IsArray() | ||
| @IsString({ each: true }) | ||
| @IsNotEmpty({ each: true }) | ||
| regionIds?: string[]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/features/product/services/product-search-mappers.helper.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { | ||
| buildPriceBuckets, | ||
| displayPrice, | ||
| } from '@/features/product/services/product-search-mappers.helper'; | ||
|
|
||
| describe('product-search mappers', () => { | ||
| describe('displayPrice', () => { | ||
| it('할인가가 있으면 할인가, 없으면 정가', () => { | ||
| expect(displayPrice({ regular_price: 40000, sale_price: 30000 })).toBe( | ||
| 30000, | ||
| ); | ||
| expect(displayPrice({ regular_price: 40000, sale_price: null })).toBe( | ||
| 40000, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('buildPriceBuckets', () => { | ||
| it('0~70,000을 5,000원 폭 14개 + "이상" 버킷 1개로 만들고 빈 구간도 0으로 채운다', () => { | ||
| const buckets = buildPriceBuckets([]); | ||
|
|
||
| expect(buckets).toHaveLength(15); | ||
| expect(buckets[0]).toEqual({ minPrice: 0, maxPrice: 5000, count: 0 }); | ||
| expect(buckets[13]).toEqual({ | ||
| minPrice: 65000, | ||
| maxPrice: 70000, | ||
| count: 0, | ||
| }); | ||
| expect(buckets[14]).toEqual({ | ||
| minPrice: 70000, | ||
| maxPrice: null, | ||
| count: 0, | ||
| }); | ||
| }); | ||
|
|
||
| it('경계값은 상위 버킷에 속하고(5,000 → [5,000, 10,000)), 상한 이상은 마지막 버킷', () => { | ||
| const buckets = buildPriceBuckets([4999, 5000, 69999, 70000, 120000]); | ||
|
|
||
| expect(buckets[0].count).toBe(1); | ||
| expect(buckets[1].count).toBe(1); | ||
| expect(buckets[13].count).toBe(1); | ||
| expect(buckets[14].count).toBe(2); | ||
| }); | ||
|
|
||
| it('폭·상한을 바꿔도 마지막 버킷 상한이 max로 잘린다', () => { | ||
| const buckets = buildPriceBuckets([7000], 3000, 7000); | ||
|
|
||
| expect(buckets.map((b) => [b.minPrice, b.maxPrice])).toEqual([ | ||
| [0, 3000], | ||
| [3000, 6000], | ||
| [6000, 7000], | ||
| [7000, null], | ||
| ]); | ||
| expect(buckets[3].count).toBe(1); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a client uses a bucket's returned
maxPriceinSearchProductsInput, the histogram and result count disagree at every boundary: this code defines the bucket as[minPrice, maxPrice)and assigns a 10,000원 product to the 10,000–15,000 bucket, whilebuildProductSearchWhereapplies the search maximum withlte, so the same product is also returned for the 5,000–10,000 selection. Return bounds compatible with the inclusive filter (or change the filter/API contract consistently) so bucket counts match the products shown.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
미반영: 버킷은 가격 슬라이더 배경의 분포 시각화용이지 클릭 필터 계약이 아님(figma 03 — 슬라이더가 임의 min/max를 보내고, 필터바 프리셋 경계는 FE 정의). half-open [min, max)는 히스토그램 표준 규약이고 SDL 주석에 명시됨. 경계 1건의 시각적 오차는 수용, 버킷을 필터 프리셋으로 쓰는 요구가 생기면 그때 계약을 맞춘다.