Skip to content

Commit

Permalink
Merge pull request #76 from loftwah/dl/hidden-link-fix
Browse files Browse the repository at this point in the history
Dl/hidden link fix
  • Loading branch information
loftwah authored Sep 1, 2024
2 parents 8a53fc3 + 0330af5 commit bf0c727
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
7 changes: 5 additions & 2 deletions app/controllers/analytics_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# app/controllers/analytics_controller.rb

class AnalyticsController < ApplicationController
before_action :set_user
before_action :check_analytics_visibility
Expand Down Expand Up @@ -33,8 +35,9 @@ def fetch_cached_data(key, &block)
Rails.cache.fetch("#{cache_key_with_version}/#{key}", expires_in: CACHE_EXPIRATION, &block)
end

# Update this method to exclude hidden links
def fetch_link_analytics
@user.links.includes(:link_clicks).map do |link|
@user.links.where(hidden: false).includes(:link_clicks).map do |link|
{
id: link.id,
title: link.title,
Expand Down Expand Up @@ -105,4 +108,4 @@ def fetch_browser_data
def cache_key_with_version
"user_#{@user.id}_analytics_v1"
end
end
end
4 changes: 2 additions & 2 deletions app/views/pages/home.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<svg class="w-12 h-12 mb-4 text-lime-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
</svg>
<h3 class="text-xl font-semibold mb-2 text-white">Custom Links Management</h3>
<h3 class="text-xl font-semibold mb-2 text-white">Links Management</h3>
<p class="text-gray-400 text-center">Create, edit, and manage links effortlessly. Customize icons, descriptions, and visibility to better represent your brand or personal profile.</p>
</div>
<div class="flex flex-col items-center justify-center p-6 bg-gray-800 rounded-lg shadow-md">
Expand All @@ -47,7 +47,7 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v8m0 0L8 12m4 4l4-4"></path>
</svg>
<h3 class="text-xl font-semibold mb-2 text-white">Social Media Integration</h3>
<p class="text-gray-400 text-center">Easily connect all your social media profiles and share your content seamlessly across platforms.</p>
<p class="text-gray-400 text-center">Effortlessly connect all your social media profiles and share your content seamlessly across various platforms, ensuring a consistent and unified online presence.</p>
</div>
<div class="flex flex-col items-center justify-center p-6 bg-gray-800 rounded-lg shadow-md">
<svg class="w-12 h-12 mb-4 text-lime-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
Expand Down
28 changes: 15 additions & 13 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,30 @@
registrations: 'users/registrations'
}

# Routes for links with standard RESTful actions
resources :links do
member do
get :track_click
end
end

# Sidekiq monitoring
require 'sidekiq/web'
require 'sidekiq-scheduler/web'
mount Sidekiq::Web => '/sidekiq'

# Custom routes for user-specific views and analytics
get '/:username/analytics', to: 'analytics#index', as: :user_analytics
get '/:username(/:theme)', to: 'links#user_links', as: :user_links, constraints: { theme: /retro|win95|win98/ }

# Health check route
get 'up' => 'rails/health#show', as: :rails_health_check

# Root route
root to: 'pages#home'

# Additional resources
# Static routes should be defined before dynamic routes
resources :achievements, only: [:index, :show, :new, :create, :edit, :update, :destroy]
end

# Routes for links with standard RESTful actions - move these above the dynamic route
resources :links do
member do
get :track_click
end
end

# Custom routes for user-specific views and analytics
get '/:username/analytics', to: 'analytics#index', as: :user_analytics

# Dynamic user-specific routes must be last to avoid conflicts with static routes
get '/:username(/:theme)', to: 'links#user_links', as: :user_links, constraints: { theme: /retro|win95|win98/ }
end

0 comments on commit bf0c727

Please sign in to comment.