Skip to content

feat(items): 未来日時のItemを一覧に表示しない#751

Merged
juneboku merged 3 commits into
mainfrom
feat/hide-far-future-items
Jun 7, 2026
Merged

feat(items): 未来日時のItemを一覧に表示しない#751
juneboku merged 3 commits into
mainfrom
feat/hide-far-future-items

Conversation

@juneboku

@juneboku juneboku commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • /items に未来の published_at を持つ Item が先頭に並んでしまう問題に対処
  • Item.published_before(Time.current) で、現在時刻より未来の Item は表示しない (割り切り)
  • 「新しい順」の表示順 (order(published_at: :desc, title: :desc)) はそのまま維持
  • 絞り込みは Item.published_before(time) scope に切り出し済み (レビュー反映)
  • channels#show 等の他の表示箇所は今回は対象外 (意図的にそのまま)

Test plan

  • test/integration/items_test.rb を追加 (TDD)
    • 過去の Item は表示される
    • 未来の Item は表示されない
  • rails test test/integration/items_test.rb が green
  • rubocop オフェンスなし

遠い未来の published_at が設定された Item が /items の先頭に
並んでしまうため、現在から1ヶ月後より未来のものを表示対象から除外する。
新しい順の表示順は維持。
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、アイテム一覧ページにおいて遠い未来の日時を持つアイテムが上位に表示されてしまう問題を修正するものです。公開日時が1ヶ月以内のアイテムのみを抽出するようにクエリを制限し、表示の整合性を向上させました。

Highlights

  • Item Visibility Filtering: Updated the items index query to exclude items with a published_at date further than one month in the future.
  • Integration Testing: Added a new integration test suite to verify that items within the one-month window are displayed while those beyond it are hidden.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


未来の日時 一覧から消え 今が見える コードの工夫 静かなる修正

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request limits the items displayed in the index action to those published within one month from now and adds integration tests to verify this behavior. The review feedback suggests refactoring the query logic into a reusable scope within the Item model to keep the controller clean.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread app/controllers/items_controller.rb Outdated
def index
page = (params[:page].presence || 1).to_i
@items = Item.preload(:pawprints).eager_load(:channel).order(published_at: :desc, title: :desc).page(page).per(48)
@items = Item.where("published_at <= ?", 1.month.from_now).preload(:pawprints).eager_load(:channel).order(published_at: :desc, title: :desc).page(page).per(48)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

コントローラー内に直接 where("published_at <= ?", 1.month.from_now) というクエリロジックを記述するのではなく、Item モデルにスコープ(scope)として定義することを推奨します。これにより、コントローラーがシンプルに保たれ、将来的に他の場所で同様のフィルタリングを行う際にも再利用しやすくなります。

モデル側への実装例:

# app/models/item.rb
scope :published_before, ->(time) { where("published_at <= ?", time) }
    @items = Item.published_before(1.month.from_now).preload(:pawprints).eager_load(:channel).order(published_at: :desc, title: :desc).page(page).per(48)

juneboku added 2 commits June 8, 2026 07:47
レビュー指摘を受けて、コントローラ直書きのクエリを
Item.published_before scope に整理。挙動は変えない。
1ヶ月の猶予を持たせる方針から、現在時刻より未来のものは
すべて表示しない方針に変更。割り切ってシンプルにする。
@juneboku juneboku changed the title feat(items): 1ヶ月より先の未来日時のItemを一覧に表示しない feat(items): 未来日時のItemを一覧に表示しない Jun 7, 2026
@juneboku juneboku merged commit 1d31c1b into main Jun 7, 2026
3 checks passed
@juneboku juneboku deleted the feat/hide-far-future-items branch June 7, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant