AI: #279 検索のワイルドカード (#488)

Refs #279

Branch mode: `continue`; base: `main`; head: `feature/279`

Implementation model: `gpt-6.1-sol` / reasoning: `medium`

## Automated implementation (requires human review)
`backend/spec/requests/tags_spec.rb` を修正しました。`_` 単独検索で共通データの `spec_tag` まで一致するため、このテスト内だけ名前を `background-tag` に変更しました。

本体コードの変更・テスト追加はありません。差分の空白検査は通過しました。テストは指示どおり自身では実行せず、コントローラーの検証に引き継ぎます。

過去の `event_id` 制約エラーは原因を特定できておらず、解消済みとは判断していません。

## Verification
**PASS**: bundle check, /usr/bin/python3 /opt/gitea-codex-v4/prepare_btrc_test.py, bundle exec rspec
- A passing test suite is not a substitute for human UI/security review.
- The repository owner alone reviews changes. No AI review is executed.
- Do not merge before human acceptance and required checks.

---------

Co-authored-by: Codex Night Worker <codex-night@localhost>
Co-authored-by: みてるぞ <miteruzo@naver.com>
Co-authored-by: miteruzo <miteruzo@naver.com>
Reviewed-on: #488
Co-authored-by: テツノニジカ <969+codex-bot@noreply.localhost>
このコミットはプルリクエスト #488 でマージされました。
このコミットが含まれているのは:
2026-11-23 00:28:18 +09:00
committed by みてるぞ
co-authored by Codex Night Worker みてるぞ
コミット c1375c05a5
6個のファイルの変更、176行の追加、9行の削除
+39
ファイルの表示
@@ -516,6 +516,45 @@ RSpec.describe 'Posts API', type: :request do
end
end
[:title, :url].each do |field|
context "when #{field} contains wildcards" do
let!(:search_posts) do
values = [
'needle%25end', 'needleX25end', 'needle_end',
'needleXend', 'needleABend', 'needle%25_end']
values.map.with_index do |value, index|
Post.create!(uploaded_user: user,
title: field == :title ? "prefix #{value} suffix" : 'url search post',
url: field == :url ? "https://example.com/prefix-#{value}-suffix" :
"https://example.com/title-search-#{index}")
end
end
{
'%' => [0, 5],
'_' => [2, 5],
'needle%25end' => [0],
'needle_end' => [2],
'needle*end' => [0, 1, 2, 3, 4, 5],
'needle?end' => [2, 3],
'needle??end' => [4],
'needle%*end' => [0, 5],
'needle_?nd' => [2],
'needle%25_end' => [5],
'needle%25_*end' => [5]
}.each do |query, expected_indices|
it "matches #{query.inspect} using only * and ? as wildcards" do
get '/posts', params: { field => query }
expect(response).to have_http_status(:ok)
expected_ids = expected_indices.map { |i| search_posts[i].id }
expect(json.fetch('posts').map { |p| p['id'] }).to match_array(expected_ids)
expect(json.fetch('count')).to eq(expected_ids.size)
end
end
end
end
context 'when created_from/created_to are provided' do
let(:t_created_hit) { Time.zone.local(2010, 1, 5, 12, 0, 0) }
let(:t_created_miss) { Time.zone.local(2012, 1, 5, 12, 0, 0) }