Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

HOME画面に、レビュー件数(総数)を表示する #235

Merged
merged 9 commits into from
May 23, 2022

Conversation

takmita
Copy link
Contributor

@takmita takmita commented May 20, 2022

close #222

@takmita takmita added タスク [Deprecated] スクラムでの開発をしなくなったため非推奨 APP labels May 20, 2022
@takmita takmita self-assigned this May 20, 2022
@takmita takmita force-pushed the review-count-home-view branch from c84b3c0 to 6fc535f Compare May 20, 2022 03:08
@takmita takmita linked an issue May 20, 2022 that may be closed by this pull request
@takuya-okamoto-esm
Copy link
Contributor

takuya-okamoto-esm commented May 20, 2022

テストが落ちていますね。
坂部さんが追加したテストモジュールに関するエラーっぽいので、rebase/mergeしたときに
何かを消してしまったのかもしれません。
元のmainブランチと比較するとすぐにわかるかなと思います。

この手の問題があるので、PRを出す前には一通りのチェック(lint/type-check/test)は
手元で掛けるようにした方が良いですね。
今回は特にActionsが動かなかったので余計に気付かなかった。。。

root@28a303426a3d:/workspaces/boat-bee# make test 
pipenv run pytest
============================================================================================================================== test session starts ==============================================================================================================================
platform linux -- Python 3.9.11, pytest-7.1.1, pluggy-1.0.0
rootdir: /workspaces/boat-bee
collected 53 items                                                                                                                                                                                                                                                              

bee_slack_app/repository/test_google_books_repository.py .......                                                                                                                                                                                                          [ 13%]
bee_slack_app/repository/test_review_repository.py ............                                                                                                                                                                                                           [ 35%]
bee_slack_app/repository/test_user_repository.py .........                                                                                                                                                                                                                [ 52%]
bee_slack_app/service/test_book_search.py ....                                                                                                                                                                                                                            [ 60%]
bee_slack_app/service/test_recommend.py ....                                                                                                                                                                                                                              [ 67%]
bee_slack_app/service/test_review.py ........EE.                                                                                                                                                                                                                          [ 88%]
bee_slack_app/service/test_user.py ......                                                                                                                                                                                                                                 [100%]

==================================================================================================================================== ERRORS =====================================================================================================================================
________________________________________________________________________________________________________________ ERROR at setup of test_post_reviewでレビューを投稿できること ________________________________________________________________________________________________________________
file /workspaces/boat-bee/bee_slack_app/service/test_review.py, line 361
  def test_post_reviewでレビューを投稿できること(
E       fixture 'mocker' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/workspaces/boat-bee/bee_slack_app/service/test_review.py:361
__________________________________________________________________________________________________ ERROR at setup of test_post_reviewでreview_repositoryの処理でエラーが発生した場合Noneを返すこと __________________________________________________________________________________________________
file /workspaces/boat-bee/bee_slack_app/service/test_review.py, line 397
  def test_post_reviewでreview_repositoryの処理でエラーが発生した場合Noneを返すこと(
E       fixture 'mocker' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/workspaces/boat-bee/bee_slack_app/service/test_review.py:397
============================================================================================================================ short test summary info ============================================================================================================================
ERROR bee_slack_app/service/test_review.py::test_post_reviewでレビューを投稿できること
ERROR bee_slack_app/service/test_review.py::test_post_reviewでreview_repositoryの処理でエラーが発生した場合Noneを返すこと
========================================================================================================================= 51 passed, 2 errors in 9.37s ==========================================================================================================================
make: *** [Makefile:28: test] Error 1
root@28a303426a3d:/workspaces/boat-bee# 

Comment on lines 52 to 53
limit: int,
limit: Optional[int],
keys: list[ReviewItemKey],
Copy link
Contributor

Choose a reason for hiding this comment

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

limit を空(None)でも受けられるようにしたい場合、空で呼ぶ時には指定しなくても良いように
デフォルト引数にしてしまうのが良いと思います。

次のkeysも同様で、指定なしで呼ぶ時には、空(Noneや空のlist)を渡すよりは、引数をつけない
という形にした方が良いです。

多分こんな感じで書けるはず。

    limit: Optional[int] = None,
    keys: list[ReviewItemKey] = [],

参考:

こうすることで、今回は呼び出す側(homeのViewControllde)からはlimitやkeysのことを意識せずに
呼べるのでコードがスッキリします。
例えば、homeのコードだけを見た人は、「なんでlimitとかkeysとか渡してるの?」となるので。

多分呼ぶ側はこうなるかな。

        reviews = get_reviews(logger=getLogger())

homeからすると、limitもkeysも知らなくていことなので、わざわざ空の値を用意して入れるのではなく
最初から引数として渡さない方が良いかなと思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@takuya-okamoto-esm 対応しました。

reviews = get_reviews(logger=getLogger(), limit=None, keys=[])

if reviews is None:
review_count_all = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

命名規則は半分趣味の問題ですが。

一般的に、変数名は名詞にするのが良い感じになりやすいですね。
その場合「すべての」という修飾は単語の前に持ってきた方が英語っぽいので
例えば岡本だったら total_review_count とかにするかなあ、と思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

変数名を見直しました。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

変数名を見直しました。

@takuya-okamoto-esm
Copy link
Contributor

テストが落ちていますね。

失礼、make init 忘れてました。(テストPASSしてます)

@takmita takmita merged commit 8a2f585 into main May 23, 2022
@takmita takmita deleted the review-count-home-view branch May 23, 2022 00:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
APP タスク [Deprecated] スクラムでの開発をしなくなったため非推奨
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HOME画面に、レビュー件数(総数)を表示する
4 participants