-
Notifications
You must be signed in to change notification settings - Fork 1
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
[feat]フィルタありのactivitesのAPI実装 #812
[feat]フィルタありのactivitesのAPI実装 #812
Conversation
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.
大変申し訳ないけど、パスパラメータで年度も追加して欲しい、、、、
すみません
yearだけ |
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.
いくつかスペースが気になりました!
コメントもしました!
WHERE | ||
1=1 ` |
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.
ここっているんですかね?
おそらくWHEREがないとエラーが出るから付けてるかと思います
何も条件がない場合にWHEREをつける形とかだとできますかね
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.
今回フィルタに使用している要素がすべて任意で外すことができるため、どの要素からWHEREが始まるかわからないため、1=1の常にTRUEの条件を設定し、そのあとにそれぞれのフィルタを加えるように実装しています。
years | ||
ON | ||
year_periods.year_id = years.id | ||
WHERE |
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.
WHERE | |
WHERE |
スペースを消してください
|
||
// keywordフィルタを追加 | ||
if keyword != "" { | ||
query += ` AND |
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.
query += ` AND | |
query += ` AND |
// isDoneフィルタを追加 | ||
if isDone != "" { | ||
if isDone != "all" { | ||
query += ` AND |
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.
query += ` AND | |
query += ` AND |
if len(sponsorStyleIDs) > 0 { | ||
// プレースホルダーを生成 | ||
placeholders := strings.Join(sponsorStyleIDs, ",") | ||
query += ` AND |
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.
query += ` AND | |
query += ` AND |
// activityに紐づくsponserとusersをフィルタを考慮して取得する | ||
func (ar *activityRepository) FindFilteredDetail(c context.Context, isDone string, sponsorStyleIDs []string, year string, keyword string) (*sql.Rows, error) { | ||
query := ` | ||
SELECT |
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.
SELECT | |
SELECT |
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.
LGTM
対応Issue
resolve #800
概要
画面スクリーンショット等
URL
スクリーンショット
テスト項目
make build
をするmake up
で立ち上げるlocalhost:1323/swagger
でSwaggerを開くsponsoractivites/filtered_details
のAPIで適当に動かし、動作確認をする。備考