mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 22:15:14 +00:00
account for zero minutes on profile cards (#729)
This commit is contained in:
parent
4f65cbe6d0
commit
624ffed250
2 changed files with 6 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<% if projects.present? && projects.size > 0 %>
|
||||
<%
|
||||
max = projects.map { |p| p[:duration] }.max || 1
|
||||
max = projects.map { |p| p[:duration].to_f }.select { |d| d.finite? && d > 0 }.max || 1
|
||||
%>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<% projects.each do |project| %>
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
<div class="w-full h-2 bg-darkless rounded-full overflow-hidden">
|
||||
<div
|
||||
class="h-full bg-primary rounded-full"
|
||||
style="width: <%= [project[:duration].to_f / max.to_f * 100, 100].min %>%;"></div>
|
||||
style="width: <%= [(project[:duration].to_f.finite? ? project[:duration].to_f : 0) / max.to_f * 100, 100].min %>%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -52,12 +52,12 @@
|
|||
<div class="border border-primary rounded-xl p-5">
|
||||
<h2 class="text-xl font-bold mb-4">Top Languages</h2>
|
||||
<div class="flex flex-col gap-3">
|
||||
<% max_duration = @top_languages.values.max %>
|
||||
<% max_duration = @top_languages.values.map(&:to_f).select { |d| d.finite? && d > 0 }.max || 1 %>
|
||||
<% @top_languages.each do |language, duration| %>
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-24 text-sm text-gray-300 truncate"><%= ApplicationController.helpers.display_language_name(language) || "Unknown" %></div>
|
||||
<div class="flex-1 h-6 bg-darkless rounded-full overflow-hidden relative">
|
||||
<div class="h-full bg-primary rounded-full flex items-center justify-end pr-2" style="width: <%= [duration.to_f / max_duration * 100, 100].min.round %>%">
|
||||
<div class="h-full bg-primary rounded-full flex items-center justify-end pr-2" style="width: <%= [(duration.to_f.finite? ? duration.to_f : 0) / max_duration * 100, 100].min.round %>%">
|
||||
<span class="text-xs font-medium text-white"><%= ApplicationController.helpers.short_time_simple(duration) %></span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -71,12 +71,12 @@
|
|||
<div class="border border-primary rounded-xl p-5">
|
||||
<h2 class="text-xl font-bold mb-4">Favorite Editors</h2>
|
||||
<div class="flex flex-col gap-3">
|
||||
<% max_duration = @top_editors.values.max %>
|
||||
<% max_duration = @top_editors.values.map(&:to_f).select { |d| d.finite? && d > 0 }.max || 1 %>
|
||||
<% @top_editors.each do |editor, duration| %>
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-24 text-sm text-gray-300 truncate"><%= editor %></div>
|
||||
<div class="flex-1 h-6 bg-darkless rounded-full overflow-hidden relative">
|
||||
<div class="h-full bg-primary rounded-full flex items-center justify-end pr-2" style="width: <%= [duration.to_f / max_duration * 100, 100].min.round %>%">
|
||||
<div class="h-full bg-primary rounded-full flex items-center justify-end pr-2" style="width: <%= [(duration.to_f.finite? ? duration.to_f : 0) / max_duration * 100, 100].min.round %>%">
|
||||
<span class="text-xs font-medium text-white"><%= ApplicationController.helpers.short_time_simple(duration) %></span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue