Skip to content

Conversation

@fujiwara-e
Copy link
Contributor

@fujiwara-e fujiwara-e commented Oct 15, 2025

  • Task.where を用いて,state が todo のタスクを絞り込んでいたのを task モデルの active スコープを用いるように修正した.

@fujiwara-e
Copy link
Contributor Author

修正内容

  • 検索ワードによる絞り込みと,todo のみ表示を組み合わせられるように修正した.

懸念点

  • hidden_field を用いているため,param が増えた場合に修正する必要がある.

@fujiwara-e fujiwara-e requested a review from Copilot October 28, 2025 06:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the task retrieval logic in the tasks controller to use the active scope from the Task model instead of directly filtering by state using Task.where. The changes improve code maintainability by centralizing the "todo" state filtering logic.

Key changes:

  • Replaced direct state filtering with the Task.active scope for the "only_todo" filter
  • Modified sort column references from state_priority to state.priority to properly reference the joined state table
  • Added hidden field tags to preserve query parameters across form submissions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
app/controllers/tasks_controller.rb Refactored to use Task.active scope instead of direct state filtering; updated sort column references to use joined state table syntax
app/views/tasks/index.html.erb Added hidden field tags to preserve only_todo and search query parameters during form submissions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


<% if params[:q].present? %>
<% params[:q].each do |key, value| %>
<%= hidden_field_tag "q[#{key}]", value %>
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

Potential XSS vulnerability: params[:q] is being iterated without sanitization. If params[:q] contains nested hashes or arrays, this could lead to unexpected behavior or security issues. Consider validating the structure of params[:q] and sanitizing the values before rendering them in hidden fields.

Suggested change
<%= hidden_field_tag "q[#{key}]", value %>
<% if value.is_a?(String) || value.is_a?(Numeric) || value == true || value == false %>
<%= hidden_field_tag "q[#{key}]", h(value) %>
<% end %>

Copilot uses AI. Check for mistakes.
@miyake13000
Copy link
Contributor

LGTM

@miyake13000 miyake13000 merged commit a31a0ef into nomlab:main Oct 28, 2025
2 checks passed
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.

2 participants