mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-20 00:35:22 +00:00
Waka projects -> project_labels
This commit is contained in:
parent
d87275781c
commit
b9c55e2fe1
3 changed files with 7 additions and 6 deletions
|
|
@ -2,7 +2,7 @@ class StaticPagesController < ApplicationController
|
|||
def index
|
||||
if current_user
|
||||
@project_names = current_user.project_names
|
||||
@projects = current_user.projects
|
||||
@projects = current_user.project_labels
|
||||
@current_project = current_user.active_project
|
||||
end
|
||||
end
|
||||
|
|
@ -11,13 +11,14 @@ class StaticPagesController < ApplicationController
|
|||
return unless current_user
|
||||
|
||||
@project_durations = Rails.cache.fetch("user_#{current_user.id}_project_durations", expires_in: 1.minute) do
|
||||
project_times = current_user.heartbeats.group(:project).duration_seconds
|
||||
project_names = current_user.project_names
|
||||
projects = current_user.projects
|
||||
projects = current_user.project_labels
|
||||
|
||||
project_names.map do |project|
|
||||
{
|
||||
project: projects.find { |p| p.project_key == project }&.label || project || "Unknown",
|
||||
duration: current_user.heartbeats.where(project: project).duration_seconds
|
||||
duration: project_times[project]
|
||||
}
|
||||
end.filter { |p| p[:duration].positive? }.sort_by { |p| p[:duration] }.reverse
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
class Project < WakatimeRecord
|
||||
class ProjectLabel < WakatimeRecord
|
||||
self.table_name = "project_labels"
|
||||
|
||||
has_many :heartbeats,
|
||||
|
|
@ -11,10 +11,10 @@ class User < ApplicationRecord
|
|||
primary_key: :slack_uid,
|
||||
class_name: "Heartbeat"
|
||||
|
||||
has_many :projects,
|
||||
has_many :project_labels,
|
||||
foreign_key: :user_id,
|
||||
primary_key: :slack_uid,
|
||||
class_name: "Project"
|
||||
class_name: "ProjectLabel"
|
||||
|
||||
def admin?
|
||||
is_admin
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue