Open
Conversation
kenji7157
reviewed
Mar 3, 2025
| keys.each do |key| | ||
| if usage >= key | ||
| unit_price_kwh = thresholds[key] | ||
| usage_price = (unit_price_kwh * usage).round(2) |
Member
There was a problem hiding this comment.
1000kwhの使用量でAPI実行した場合に、東京電力・従量電灯Bの場合に、電力量料金が 1000kwh * 30.57 になっており、段階的に「使用量 * 単価」の計算がされていないようです。
https://www.tepco.co.jp/ep/private/plan2/chargelist04.html#sec03
kenji7157
reviewed
Mar 3, 2025
| errors: | ||
| empty_parameter: 'リクエストパラメータにampereとusageを設定してください' | ||
| invalid_parameter_type: 'ampereとusageはいずれも数値を設定してください' | ||
| invalid_contract_ampere: 'ampereの値が正しくありません' |
Member
There was a problem hiding this comment.
どのような値を設定すれば正しいのか判別できるエラーメッセージだと親切かと思いました。
kenji7157
reviewed
Mar 3, 2025
| end | ||
|
|
||
| # yamlからパラメータ読み込み | ||
| def import_price_from_yaml(ampere, usage) |
Member
There was a problem hiding this comment.
import_price_from_yaml関数が、ymlからデータを読み込む以上の処理をしています。
関数内の処理を別関数に切り出すなどした方が保守性・可読性は上がると思いましたが、いかがでしょうか。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
お世話になっております。中村と申します。
ご共有いただいていたチャレンジ課題について実装しましたのでご連絡となります。
お手数ですがご確認いただけますと幸いです。
よろしくお願いいたします。
実装内容
こちらのとおり、与えられたパラメータから電気料金を返却するAPIの実装
具体的な内容