Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
68fd066
新規Railsアプリの作成
MasafumiKondo07 Sep 11, 2022
ae5de6d
model、migrationファイルの追加
MasafumiKondo07 Sep 20, 2022
2eddab0
マスターデータ用のCSVの作成と、seedファイルの記述
MasafumiKondo07 Sep 20, 2022
82630c7
プランごとの電気料金を返すAPIの作成
MasafumiKondo07 Sep 20, 2022
45a0e14
重量料金計算ロジックを重量料金を扱うモデルへ移動
MasafumiKondo07 Oct 2, 2022
9b7a2c7
nil判定を後置ifから「 ||=」に変更
MasafumiKondo07 Oct 2, 2022
ac8e8e6
従量料金の計算方法の修正
MasafumiKondo07 Oct 3, 2022
152a767
電気料金算出ロジックをPlanモデルに寄せる
MasafumiKondo07 Oct 3, 2022
6d4fa21
従量料金を求めるロジックの修正
MasafumiKondo07 Oct 8, 2022
096506e
アプリの中で、「会社」の命名に一貫性を持たせるための修正
MasafumiKondo07 Oct 8, 2022
ca23a42
不要な項目を削除(CSV)
MasafumiKondo07 Oct 8, 2022
b550e4c
クラスメソッドの修正
MasafumiKondo07 Oct 9, 2022
6290631
rspec、factory_botの導入
MasafumiKondo07 Oct 9, 2022
21ff83c
ElectricityFeeモデルのクラスメソッドテスト用factoryの作成
MasafumiKondo07 Oct 9, 2022
2172b6e
従量料金計算クラスメソッドのテスト作成
MasafumiKondo07 Oct 9, 2022
14d1c7f
n + 1の解消
MasafumiKondo07 Oct 9, 2022
c92c96a
ファイル名が不適切だったため修正
MasafumiKondo07 Oct 9, 2022
3d03e55
基本料金のfactory作成
MasafumiKondo07 Oct 9, 2022
d87fc4d
controllerのテスト追加
MasafumiKondo07 Oct 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

純粋な質問ですが、ここのunitってどういう用途で利用されますか?恐らく「単位」を指していると思いますが、会社によって、kwhだったり、契約数だったりまちまちのものを一緒くたにしてunitと管理してしまってもよいのでしょうか。

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,name
1,東京電力エナジーパートナー
2,Loopでんき
3,東京ガス株式会社
4,JXTGでんき
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
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たっぷりプラン
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ここのidとcompany_idを分けている意図について教えてください。一緒の値であれば、まとめてしまってもいいと思います。

49 changes: 49 additions & 0 deletions 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.

40 changes: 33 additions & 7 deletions serverside_challenge_1/challenges/MasafumiKondo07/db/seeds.rb
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