Skip to content

Commit

Permalink
Update unit for sweet potato
Browse files Browse the repository at this point in the history
  • Loading branch information
muxinqi committed Oct 24, 2023
1 parent 83d51f8 commit f60d5c0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 45 deletions.
80 changes: 42 additions & 38 deletions .idea/breakfast_tracker.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ def index
finished_cooking_records = CookingRecord.includes(:meals).where("finished_at < ?", Time.now)
@total_eaten_eggs = finished_cooking_records.sum { |cr| cr.meals.sum(:egg_count) }
@total_eaten_corn = finished_cooking_records.sum { |cr| cr.meals.sum(:corn_count) }
@total_eaten_sweet_potato = finished_cooking_records.sum { |cr| cr.meals.sum(:sweet_potato_count) }
end
end
2 changes: 1 addition & 1 deletion app/views/home/_total_of_today.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
🌽玉米 <%= data[:corn] %>
</div>
<div>
🍠红薯 <%= data[:sweet_potato] %>
🍠红薯 <%= data[:sweet_potato] %>
</div>
</div>
10 changes: 5 additions & 5 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
</p>
</div>
<p class="text-sm font-medium text-gray-900">
¥1
¥1/颗
</p>
</div>
</div>
Expand All @@ -171,7 +171,7 @@
</p>
</div>
<p class="text-sm font-medium text-gray-900">
¥3
¥3/根
</p>
</div>
</div>
Expand All @@ -193,7 +193,7 @@
</p>
</div>
<p class="text-sm font-medium text-gray-900">
¥?
¥3/份
</p>
</div>
</div>
Expand Down Expand Up @@ -226,7 +226,7 @@
年度营收
</dt>
<dd class="order-first text-3xl font-semibold tracking-tight text-gray-900 sm:text-5xl">
¥<%= @total_eaten_eggs * 1 + @total_eaten_corn * 3 %>
¥<%= @total_eaten_eggs * 1 + @total_eaten_corn * 3 + @total_eaten_sweet_potato * 3 %>
</dd>
</div>
</dl>
Expand Down Expand Up @@ -276,7 +276,7 @@
<%= time_tag cooking.created_at, "data-local": "time-ago" %>
</time>
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">
🥚鸡蛋 <%= cooking.egg_count %> 个,🌽玉米 <%= cooking.corn_count %> 根,🍠红薯 <%= cooking.sweet_potato_count %>
🥚鸡蛋 <%= cooking.egg_count %> 个,🌽玉米 <%= cooking.corn_count %> 根,🍠红薯 <%= cooking.sweet_potato_count %>
</h3>
<div class="flex mb-5 -space-x-3">
<% cooking.meals.each do |meal| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_user.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
<div class="mt-3 flex items-center justify-between">
<span class="text-3xl font-bold text-gray-900 dark:text-white">
🍠红薯 <%= user.sweet_potato_count %>
🍠红薯 <%= user.sweet_potato_count %>
</span>
<div class="flex gap-x-4">
<%= button_to "-", decrease_sweet_potato_count_user_path(user), method: :patch, disabled: user.sweet_potato_count == 0, class: "text-white bg-blue-700 hover:bg-blue-800 disabled:bg-blue-400 disabled:cursor-not-allowed focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" %>
Expand Down

0 comments on commit f60d5c0

Please sign in to comment.