Skip to content
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

Merged
merged 11 commits into from
Jul 6, 2024

Conversation

KazumaSun
Copy link
Collaborator

対応Issue

resolve #800

概要

画面スクリーンショット等

  • URL
    スクリーンショット

テスト項目

  • make buildをする
  • make upで立ち上げる
  • localhost:1323/swaggerでSwaggerを開く
  • sponsoractivites/filtered_detailsのAPIで適当に動かし、動作確認をする。

備考

@KazumaSun KazumaSun requested review from hikahana and Kubosaka July 2, 2024 00:56
@KazumaSun KazumaSun self-assigned this Jul 2, 2024
Copy link
Collaborator

@Kubosaka Kubosaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

大変申し訳ないけど、パスパラメータで年度も追加して欲しい、、、、
すみません

@Kubosaka Kubosaka self-requested a review July 6, 2024 03:32
@Kubosaka
Copy link
Collaborator

Kubosaka commented Jul 6, 2024

yearだけ/activities/filtered_details/{year}/にできます?
activities/details/2024とかと合わせて、わかりやすくしたいので、、
https://zenn.dev/eri_agri/articles/859a3362db8386

Copy link
Collaborator

@Kubosaka Kubosaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いくつかスペースが気になりました!
コメントもしました!

Comment on lines 226 to 227
WHERE
1=1 `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここっているんですかね?
おそらくWHEREがないとエラーが出るから付けてるかと思います
何も条件がない場合にWHEREをつける形とかだとできますかね

Copy link
Collaborator Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WHERE
WHERE

スペースを消してください


// keywordフィルタを追加
if keyword != "" {
query += ` AND
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
query += ` AND
query += ` AND

// isDoneフィルタを追加
if isDone != "" {
if isDone != "all" {
query += ` AND
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
query += ` AND
query += ` AND

if len(sponsorStyleIDs) > 0 {
// プレースホルダーを生成
placeholders := strings.Join(sponsorStyleIDs, ",")
query += ` AND
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SELECT
SELECT

Copy link
Collaborator

@Kubosaka Kubosaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Kubosaka Kubosaka merged commit 6152f32 into develop Jul 6, 2024
1 check passed
@Kubosaka Kubosaka deleted the feat/sato/800-fitering-sponsor-activites-api branch July 6, 2024 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat]協賛活動のフィルタリングAPIの実装
2 participants