- Add 30-minute expiry window for draft tickets with automatic cleanup - Implement 3-attempt payment retry mechanism with tracking - Create background job for cleaning expired draft tickets every 10 minutes - Add comprehensive UI warnings for expiring tickets and retry attempts - Enhance dashboard to display pending draft tickets with retry options - Add payment cancellation handling with smart retry redirections - Include rake tasks for manual cleanup and statistics - Add database fields: expires_at, payment_attempts, last_payment_attempt_at, stripe_session_id - Fix payment attempt counter display to show correct attempt number (1/3, 2/3, 3/3)
48 lines
1.9 KiB
Ruby
Executable File
48 lines
1.9 KiB
Ruby
Executable File
# Controller for static pages and user dashboard
|
|
# Handles basic page rendering and user-specific content
|
|
class PagesController < ApplicationController
|
|
# Skip authentication for public pages
|
|
# skip_before_action :authenticate_user!, only: [ :home ]
|
|
before_action :authenticate_user!, only: [ :dashboard ]
|
|
|
|
# Homepage showing featured events
|
|
def home
|
|
@events = Event.published.featured.limit(3)
|
|
|
|
if user_signed_in?
|
|
redirect_to(dashboard_path)
|
|
end
|
|
end
|
|
|
|
# User dashboard showing personalized content
|
|
# Accessible only to authenticated users
|
|
def dashboard
|
|
# Metrics for dashboard cards
|
|
@booked_events = current_user.tickets.joins(:ticket_type, :event).where(events: { state: :published }).count
|
|
@events_today = Event.published.where("DATE(start_time) = ?", Date.current).count
|
|
@events_tomorrow = Event.published.where("DATE(start_time) = ?", Date.current + 1).count
|
|
@upcoming_events = Event.published.upcoming.count
|
|
|
|
# User's booked events
|
|
@user_booked_events = Event.joins(ticket_types: :tickets)
|
|
.where(tickets: { user: current_user, status: "active" })
|
|
.distinct
|
|
.limit(5)
|
|
|
|
# Draft tickets that can be retried
|
|
@draft_tickets = current_user.tickets.includes(:ticket_type, :event)
|
|
.can_retry_payment
|
|
.order(:expires_at)
|
|
|
|
# Events sections
|
|
@today_events = Event.published.where("DATE(start_time) = ?", Date.current).order(start_time: :asc)
|
|
@tomorrow_events = Event.published.where("DATE(start_time) = ?", Date.current + 1).order(start_time: :asc)
|
|
@other_events = Event.published.upcoming.where.not("DATE(start_time) IN (?)", [ Date.current, Date.current + 1 ]).order(start_time: :asc).page(params[:page])
|
|
end
|
|
|
|
# Events page showing all published events with pagination
|
|
def events
|
|
@events = Event.published.order(created_at: :desc).page(params[:page])
|
|
end
|
|
end
|