mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 16:38:23 +00:00
* fix: use owner/repo format for project badges Updates badge URLs to use GitHub-style owner/repo format (e.g., "hackclub/hackatime") instead of project names. This ensures compatibility with external badge services that expect repository paths. Changes: - Add Repository#full_path method to get owner/repo format - Update settings controller to pass both display names and repo paths - Update Badges component to display project names but use repo paths in URLs * fix: improve user lookup in API v1 stats endpoint Use the robust lookup_user method for username parameter in the /api/v1/stats endpoint to ensure consistent user lookup across all API endpoints. This properly handles Slack UIDs (HCA IDs), numeric user IDs, and usernames in the correct priority order. * fix: reduce clutter on new user homepage Simplify the new user experience by: - Removing redundant "Hello friend" text from setup notice (header already provides context) - Hiding GitHub link banner when setup notice is shown to focus user on primary action This reduces visual clutter and helps new users focus on completing setup first. * fix: enable full app layout for new OAuth application page Remove layout=false directive that was preventing the app header and navigation from appearing on the new OAuth application creation page. * fix: add antigravity editor to docs Add documentation for Antigravity, a VSCode fork from Google with built-in AI features. Includes setup instructions for tracking time with Hackatime using the WakaTime extension. * fix: improve stat card subtitle positioning Remove absolute positioning from subtitle text to allow it to flow naturally after the main value. This prevents the subtitle from being pushed to the bottom when other cards have longer content. * fix: align settings action buttons to card end on larger screens Remove width constraint from footer to allow action buttons to align to the right edge of the full card width instead of being constrained to a narrower container. * fix: improve heartbeat importer visibility on light themes Update import provider cards and radio buttons to have better contrast on light themes: - Use bg-surface-100 instead of bg-darker for better card visibility - Increase radio button border thickness and use darker border color - Add hover and focus states for better interactivity * Split up settings controller + perf + goal display * Make stat card subtitles larger * Fix AG + VS Code * Remove Shiba refs * Bundle update
49 lines
1.3 KiB
Ruby
49 lines
1.3 KiB
Ruby
class Repository < ApplicationRecord
|
|
has_many :project_repo_mappings, dependent: :destroy
|
|
has_many :users, through: :project_repo_mappings
|
|
has_many :commits, dependent: :destroy
|
|
|
|
validates :url, presence: true, uniqueness: true
|
|
validates :host, presence: true
|
|
validates :owner, presence: true
|
|
validates :name, presence: true
|
|
|
|
# Check if metadata needs refreshing (older than 1 day)
|
|
def metadata_stale?
|
|
last_synced_at.nil? || last_synced_at < 1.day.ago
|
|
end
|
|
|
|
# Get owner/repo format (e.g., "hackclub/hackatime")
|
|
def full_path
|
|
"#{owner}/#{name}"
|
|
end
|
|
|
|
# Get formatted languages list
|
|
def formatted_languages
|
|
return nil if languages.blank?
|
|
languages.split(", ").first(3).join(", ") + (languages.split(", ").length > 3 ? "..." : "")
|
|
end
|
|
|
|
# Parse owner and repo from URL
|
|
def self.parse_url(url)
|
|
if url =~ %r{https?://([^/]+)/([^/]+)/([^/]+)/?$}
|
|
{
|
|
host: $1,
|
|
owner: $2,
|
|
name: $3
|
|
}
|
|
else
|
|
raise ArgumentError, "Invalid repository URL format: #{url}"
|
|
end
|
|
end
|
|
|
|
# Find or create repository from URL
|
|
def self.find_or_create_by_url(url)
|
|
parsed = parse_url(url)
|
|
find_or_create_by(url: url) do |repo|
|
|
repo.host = parsed[:host]
|
|
repo.owner = parsed[:owner]
|
|
repo.name = parsed[:name]
|
|
end
|
|
end
|
|
end
|