mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 23:32:53 +00:00
deprecate username + name cleanup
This commit is contained in:
parent
e2401f1677
commit
109ae988a0
15 changed files with 32 additions and 30 deletions
|
|
@ -15,7 +15,7 @@ module Api
|
|||
},
|
||||
creator: {
|
||||
id: creator.id,
|
||||
username: creator.name,
|
||||
username: creator.custom_name,
|
||||
display_name: creator.display_name,
|
||||
admin_level: creator.admin_level
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ module Api
|
|||
render json: {
|
||||
user: {
|
||||
id: user.id,
|
||||
username: user.name,
|
||||
username: user.custom_name,
|
||||
display_name: user.display_name,
|
||||
slack_uid: user.slack_uid,
|
||||
slack_username: user.slack_username,
|
||||
|
|
@ -118,7 +118,7 @@ module Api
|
|||
|
||||
render json: {
|
||||
user_id: user.id,
|
||||
username: user.name,
|
||||
username: user.display_name,
|
||||
date: date.iso8601,
|
||||
timezone: user.timezone,
|
||||
heartbeats: heartbeats.map do |hb|
|
||||
|
|
@ -184,7 +184,7 @@ module Api
|
|||
|
||||
render json: {
|
||||
user_id: user.id,
|
||||
username: user.name,
|
||||
username: user.display_name,
|
||||
projects: project_data,
|
||||
total_projects: project_data.count
|
||||
}
|
||||
|
|
@ -223,12 +223,12 @@ module Api
|
|||
message: "gotcha, updated to #{trust_level}",
|
||||
user: {
|
||||
id: user.id,
|
||||
username: user.name,
|
||||
username: user.display_name,
|
||||
trust_level: user.trust_level,
|
||||
updated_at: user.updated_at
|
||||
},
|
||||
audit_log: {
|
||||
changed_by: current_user.name,
|
||||
changed_by: current_user.display_name,
|
||||
reason: reason,
|
||||
notes: notes,
|
||||
timestamp: Time.current
|
||||
|
|
@ -276,7 +276,7 @@ module Api
|
|||
columns: columns,
|
||||
rows: rows,
|
||||
row_count: rows.count,
|
||||
executed_by: current_user.name,
|
||||
executed_by: current_user.display_name,
|
||||
executed_at: Time.current
|
||||
}
|
||||
rescue => e
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module Api
|
|||
if user.persisted?
|
||||
return render json: {
|
||||
user_id: user.id,
|
||||
username: user.name,
|
||||
username: user.display_name,
|
||||
email: user.email_addresses.first&.email
|
||||
}, status: :ok
|
||||
end
|
||||
|
|
@ -46,7 +46,7 @@ module Api
|
|||
if user.save
|
||||
render json: {
|
||||
user_id: user.id,
|
||||
username: user.name,
|
||||
username: user.display_name,
|
||||
email: email
|
||||
}, status: :created
|
||||
else
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class SessionsController < ApplicationController
|
|||
|
||||
session[:impersonater_user_id] ||= current_user.id
|
||||
session[:user_id] = user.id
|
||||
redirect_to root_path, notice: "Impersonating #{user.name}"
|
||||
redirect_to root_path, notice: "Impersonating #{user.display_name}"
|
||||
end
|
||||
|
||||
def stop_impersonating
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class StaticPagesController < ApplicationController
|
|||
json_response = locals[:users].map do |user|
|
||||
{
|
||||
id: user.id,
|
||||
username: user.name,
|
||||
username: user.display_name,
|
||||
slack_username: user.slack_username,
|
||||
github_username: user.github_username,
|
||||
display_name: user.display_name,
|
||||
|
|
|
|||
2
app/jobs/cache/currently_hacking_job.rb
vendored
2
app/jobs/cache/currently_hacking_job.rb
vendored
|
|
@ -29,7 +29,7 @@ class Cache::CurrentlyHackingJob < Cache::ActivityJob
|
|||
users = users.sort_by do |user|
|
||||
[
|
||||
active_projects[user.id].present? ? 0 : 1,
|
||||
user.name.present? ? 0 : 1
|
||||
user.display_name.present? ? 0 : 1
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -468,7 +468,8 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def display_name
|
||||
return name.presence.truncate(10) if name.present?
|
||||
name = custom_name || slack_username || github_username
|
||||
return name if name.present?
|
||||
|
||||
# "zach@hackclub.com" -> "zach (email sign-up)"
|
||||
email = email_addresses&.first&.email
|
||||
|
|
@ -477,10 +478,6 @@ class User < ApplicationRecord
|
|||
email.split("@")&.first.truncate(10) + " (email sign-up)"
|
||||
end
|
||||
|
||||
def name
|
||||
custom_name || slack_username || github_username
|
||||
end
|
||||
|
||||
def most_recent_direct_entry_heartbeat
|
||||
heartbeats.where(source_type: :direct_entry).order(time: :desc).first
|
||||
end
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@
|
|||
<div class="absolute top-0 p-3 rounded-lg shadow-lg <%= trust_level_bg %>"
|
||||
data-user-id="<%= user.id %>"
|
||||
style="left: <%= column_left + 2 %>px; width: <%= min_column_width_px - 4 %>px;"
|
||||
title="User ID: <%= user.id %> - <%= user.respond_to?(:name) && user.name.present? ? h(user.name) : h(user.email_addresses.first&.email) %> | Total Coded: <%= total_coded_time_seconds && total_coded_time_seconds > 0 ? short_time_detailed(total_coded_time_seconds) : '0m' %> | TZ: <%= h(user.timezone) %>">
|
||||
title="User ID: <%= user.id %> - <%= user.respond_to?(:display_name) && user.display_name.present? ? h(user.display_name) : h(user.email_addresses.first&.email) %> | Total Coded: <%= total_coded_time_seconds && total_coded_time_seconds > 0 ? short_time_detailed(total_coded_time_seconds) : '0m' %> | TZ: <%= h(user.timezone) %>">
|
||||
<div class="flex items-center space-x-1 mb-1">
|
||||
<%= render "shared/user_mention", user: user %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ end %>">
|
|||
<%= image_tag user.avatar_url,
|
||||
size: "32x32",
|
||||
class: "rounded-full aspect-square border border-gray-300",
|
||||
alt: "#{h(user.name)}'s avatar" if user.avatar_url %>
|
||||
alt: "#{h(user.display_name)}'s avatar" if user.avatar_url %>
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<% if local_assigns.fetch(:show, []).include?(:slack) && user.slack_uid.present? %>
|
||||
<%= link_to "@#{h(user.name)}", "https://hackclub.slack.com/team/#{user.slack_uid}", target: "_blank", class: "text-blue-500 hover:underline" %>
|
||||
<%= link_to "@#{h(user.display_name)}", "https://hackclub.slack.com/team/#{user.slack_uid}", target: "_blank", class: "text-blue-500 hover:underline" %>
|
||||
<% else %>
|
||||
<%= h(user.name) %>
|
||||
<%= h(user.display_name) %>
|
||||
<% end %>
|
||||
<%# GitHub profile link - shown if :github_profile_link is in the :show array %>
|
||||
<% if github_url = user.github_profile_url # Assign to variable to avoid calling method twice %>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<% content_for :title do %>
|
||||
<%= @is_own_settings ? "My Settings" : "Settings | #{@user.name}" %>
|
||||
<%= @is_own_settings ? "My Settings" : "Settings | #{@user.display_name}" %>
|
||||
<% end %>
|
||||
|
||||
<div class="max-w-6xl mx-auto p-6 space-y-6">
|
||||
<header class="text-center mb-8">
|
||||
<h1 class="text-4xl font-bold text-white mb-2">
|
||||
<%= @is_own_settings ? "My Settings" : "Settings for #{@user.name}" %>
|
||||
<%= @is_own_settings ? "My Settings" : "Settings for #{@user.display_name}" %>
|
||||
</h1>
|
||||
<p class="text-muted text-lg">Change your Hackatime experience and preferences</p>
|
||||
</header>
|
||||
|
|
|
|||
5
db/migrate/20251021202329_deprecate_username.rb
Normal file
5
db/migrate/20251021202329_deprecate_username.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class DeprecateUsername < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
rename_column :users, :username, :deprecated_name
|
||||
end
|
||||
end
|
||||
4
db/schema.rb
generated
4
db/schema.rb
generated
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_10_18_181955) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_10_21_202329) do
|
||||
create_schema "pganalyze"
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
|
|
@ -543,7 +543,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_10_18_181955) do
|
|||
t.string "slack_uid"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "username"
|
||||
t.string "deprecated_name"
|
||||
t.string "slack_avatar_url"
|
||||
t.boolean "uses_slack_status", default: false, null: false
|
||||
t.string "slack_scopes", default: [], array: true
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ if Rails.env.development?
|
|||
end
|
||||
|
||||
puts "Created test user:"
|
||||
puts " Username: #{test_user.name}"
|
||||
puts " Username: #{test_user.display_name}"
|
||||
puts " Email: #{email.email}"
|
||||
puts " API Key: #{api_key.token}"
|
||||
puts " Sign-in Token: #{token.token}"
|
||||
|
|
|
|||
|
|
@ -246,8 +246,8 @@ class FlavorText
|
|||
r = []
|
||||
|
||||
r << "quit slacking off!" if user.slack_uid.present?
|
||||
r << "in the nick of time!" if %w[nick nicholas nickolas].include?(user.name)
|
||||
r << "just-in time!" if %w[justin justine].include?(user.name)
|
||||
r << "in the nick of time!" if %w[nick nicholas nickolas].include?(user.display_name)
|
||||
r << "just-in time!" if %w[justin justine].include?(user.display_name)
|
||||
|
||||
minutes_logged = Cache::MinutesLoggedJob.perform_now
|
||||
r << "in the past hour, #{minutes_logged} minutes have passed" if minutes_logged > 0
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class TestWakatimeService
|
|||
def generate_summary
|
||||
summary = {}
|
||||
|
||||
summary[:username] = @user.name if @user.present?
|
||||
summary[:username] = @user.display_name if @user.present?
|
||||
summary[:user_id] = @user.id.to_s if @user.present?
|
||||
summary[:is_coding_activity_visible] = true if @user.present?
|
||||
summary[:is_other_usage_visible] = true if @user.present?
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class WakatimeService
|
|||
def generate_summary
|
||||
summary = {}
|
||||
|
||||
summary[:username] = @user.name if @user.present?
|
||||
summary[:username] = @user.display_name if @user.present?
|
||||
summary[:user_id] = @user.id.to_s if @user.present?
|
||||
summary[:is_coding_activity_visible] = true if @user.present?
|
||||
summary[:is_other_usage_visible] = true if @user.present?
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue