Conversation
api/pyproject.toml
Outdated
| ] | ||
| prod=[ | ||
| "birdxplorer_common @ git+https://github.com/codeforjapan/BirdXplorer.git@main#subdirectory=common", | ||
| "birdxplorer_common @ git+https://github.com/codeforjapan/BirdXplorer.git@feature/138#subdirectory=common", |
There was a problem hiding this comment.
search_notes_with_posts と count_search_results のフィルタを適用する部分は private 関数に切り出してまとめてもいいかもしれません。(他のところにもありますので、一気にまとめたくなるかもしれませんが、一旦これだけやる想定です)
There was a problem hiding this comment.
@yu23ki14
予期せぬ挙動を起こす可能性があるため、修正したほうが良さそうな部分についてコメントしました 🙏
api/birdxplorer_api/routers/data.py
Outdated
| # Generate pagination URLs | ||
| base_url = str(request.url).split("?")[0] | ||
| next_offset = offset + limit | ||
| prev_offset = max(offset - limit, 0) | ||
| next_url = None | ||
| if next_offset < total_count: | ||
| next_url = f"{base_url}?offset={next_offset}&limit={limit}" | ||
| prev_url = None | ||
| if offset > 0: | ||
| prev_url = f"{base_url}?offset={prev_offset}&limit={limit}" |
There was a problem hiding this comment.
[MUST] (Viewer ユーザー影響あり)
?post_includes_text=地震&offset=0&limit=4 のように limit / offset 以外が指定されたクエリの場合、
next が ?offset=4&limit=4 となってしまうので urllib.parse を使うなどして現在のクエリをマージする実装にしないと予想外の挙動になりそうです!
api/birdxplorer_api/routers/data.py
Outdated
| if note_created_at_from is not None and isinstance(note_created_at_from, str): | ||
| note_created_at_from = ensure_twitter_timestamp(note_created_at_from) | ||
| if note_created_at_to is not None and isinstance(note_created_at_to, str): | ||
| note_created_at_to = ensure_twitter_timestamp(note_created_at_to) |
There was a problem hiding this comment.
[MUST]
ensure_twitter_timestamp に現在時刻より未来の値を渡すと
OverflowError: signed integer is greater than maximum が出ていそうです。
これは入力されうる異常値なので、ハンドリングして DB クエリに 異常値を渡さないように変更したほうが良さそうです。
[imo]
ensure_twitter_timestamp からは一般的な Error を投げて API Handler 側で HTTPException を投げ直すのが見通しが良さそうに思いました!
NoteとPostを統合的に検索する
/api/v1/data/searchを実装。変更点
BirdXplorer/api/birdxplorer_api/routers/data.py
Line 418 in e4fce05
BirdXplorer/common/birdxplorer_common/storage.py
Line 510 in e4fce05
BirdXplorer/common/birdxplorer_common/storage.py
Line 604 in e4fce05
テストコードは
./tests/test_search.pyに記述メモ