-
Notifications
You must be signed in to change notification settings - Fork 45
電気料金比較APIの作成 #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MasafumiKondo07
wants to merge
19
commits into
enechange:master
Choose a base branch
from
MasafumiKondo07:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
電気料金比較APIの作成 #29
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
68fd066
新規Railsアプリの作成
MasafumiKondo07 ae5de6d
model、migrationファイルの追加
MasafumiKondo07 2eddab0
マスターデータ用のCSVの作成と、seedファイルの記述
MasafumiKondo07 82630c7
プランごとの電気料金を返すAPIの作成
MasafumiKondo07 45a0e14
重量料金計算ロジックを重量料金を扱うモデルへ移動
MasafumiKondo07 9b7a2c7
nil判定を後置ifから「 ||=」に変更
MasafumiKondo07 ac8e8e6
従量料金の計算方法の修正
MasafumiKondo07 152a767
電気料金算出ロジックをPlanモデルに寄せる
MasafumiKondo07 6d4fa21
従量料金を求めるロジックの修正
MasafumiKondo07 096506e
アプリの中で、「会社」の命名に一貫性を持たせるための修正
MasafumiKondo07 ca23a42
不要な項目を削除(CSV)
MasafumiKondo07 b550e4c
クラスメソッドの修正
MasafumiKondo07 6290631
rspec、factory_botの導入
MasafumiKondo07 21ff83c
ElectricityFeeモデルのクラスメソッドテスト用factoryの作成
MasafumiKondo07 2172b6e
従量料金計算クラスメソッドのテスト作成
MasafumiKondo07 14d1c7f
n + 1の解消
MasafumiKondo07 c92c96a
ファイル名が不適切だったため修正
MasafumiKondo07 3d03e55
基本料金のfactory作成
MasafumiKondo07 d87fc4d
controllerのテスト追加
MasafumiKondo07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
serverside_challenge_1/challenges/MasafumiKondo07/db/master_data_files/basic_charges.csv
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| plan_id,ampere,unit,price | ||
| 1,10,1,286.00 | ||
| 1,15,1,429.00 | ||
| 1,20,1,572.00 | ||
| 1,30,1,858.00 | ||
| 1,40,1,1144.00 | ||
| 1,50,1,1430.00 | ||
| 1,60,1,1716.00 | ||
| 2,10,1,0.00 | ||
| 2,15,1,0.00 | ||
| 2,20,1,0.00 | ||
| 2,30,1,0.00 | ||
| 2,40,1,0.00 | ||
| 2,50,1,0.00 | ||
| 2,60,1,0.00 | ||
| 3,30,1,858.00 | ||
| 3,40,1,1144.00 | ||
| 3,50,1,1430.00 | ||
| 3,60,1,1716.00 | ||
| 4,30,1,858.00 | ||
| 4,40,1,1144.00 | ||
| 4,50,1,1430.00 | ||
| 4,60,1,1716.80 | ||
5 changes: 5 additions & 0 deletions
5
serverside_challenge_1/challenges/MasafumiKondo07/db/master_data_files/companies.csv
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| id,name | ||
| 1,東京電力エナジーパートナー | ||
| 2,Loopでんき | ||
| 3,東京ガス株式会社 | ||
| 4,JXTGでんき |
12 changes: 12 additions & 0 deletions
12
serverside_challenge_1/challenges/MasafumiKondo07/db/master_data_files/electricity_fees.csv
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| plan_id,classification_min,classification_max,unit,price | ||
| 1,0,120,1,19.88 | ||
| 1,121,300,1,26.48 | ||
| 1,301,,1,30.57 | ||
| 2,0,,1,26.40 | ||
| 3,0,140,1,23.67 | ||
| 3,141,350,1,23.88 | ||
| 3,351,,1,26.41 | ||
| 4,0,120,1,19.88 | ||
| 4,121,300,1,26.48 | ||
| 4,301,600,1,25.08 | ||
| 4,601,,1,26.15 |
5 changes: 5 additions & 0 deletions
5
serverside_challenge_1/challenges/MasafumiKondo07/db/master_data_files/plans.csv
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| id,company_id,name | ||
| 1,1,従量電灯B | ||
| 2,2,おうちプラン | ||
| 3,3,ずっとも電気1 | ||
| 4,4,従量電灯Bたっぷりプラン | ||
|
||
49 changes: 49 additions & 0 deletions
49
serverside_challenge_1/challenges/MasafumiKondo07/db/schema.rb
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
40 changes: 33 additions & 7 deletions
40
serverside_challenge_1/challenges/MasafumiKondo07/db/seeds.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,33 @@ | ||
| # This file should contain all the record creation needed to seed the database with its default values. | ||
| # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). | ||
| # | ||
| # Examples: | ||
| # | ||
| # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) | ||
| # Character.create(name: "Luke", movie: movies.first) | ||
| require "csv" | ||
|
|
||
| CSV.foreach('db/master_data_files/companies.csv', headers: true) do |row| | ||
| Company.create( | ||
| name: row['name'] | ||
| ) | ||
| end | ||
|
|
||
| CSV.foreach('db/master_data_files/plans.csv', headers: true) do |row| | ||
| Plan.create( | ||
| company_id: row['company_id'], | ||
| name: row['name'] | ||
| ) | ||
| end | ||
|
|
||
| CSV.foreach('db/master_data_files/basic_charges.csv', headers: true) do |row| | ||
| BasicCharge.create( | ||
| plan_id: row['plan_id'], | ||
| ampere: row['ampere'], | ||
| unit: row['unit'], | ||
| price: row['price'] | ||
| ) | ||
| end | ||
|
|
||
| CSV.foreach('db/master_data_files/electricity_fees.csv', headers: true) do |row| | ||
| ElectricityFee.create( | ||
| plan_id: row['plan_id'], | ||
| classification_min: row['classification_min'], | ||
| classification_max: row['classification_max'], | ||
| unit: row['unit'], | ||
| price: row['price'] | ||
| ) | ||
| end |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
純粋な質問ですが、ここのunitってどういう用途で利用されますか?恐らく「単位」を指していると思いますが、会社によって、kwhだったり、契約数だったりまちまちのものを一緒くたにしてunitと管理してしまってもよいのでしょうか。