songtianlun
dd6cd0451d
- Integrate Ahoy gem for tracking user events and visits - Create models for Ahoy events and visits - Implement admin interfaces for managing events and visits - Add background job for cleaning up old analytics data - Update application controller and other relevant controllers to track specific actions This commit implements a comprehensive event tracking system that logs user interactions within the application. Additionally, it includes mechanisms for managing and cleaning historical visit and event data, ensuring efficient data handling.
43 lines
1.5 KiB
Ruby
43 lines
1.5 KiB
Ruby
class CitiesController < ApplicationController
|
|
def index
|
|
@regions = Region.includes(:countries).order(:name)
|
|
@cities = City.includes(:country, country: :region).order(:name)
|
|
|
|
if params[:region]
|
|
@current_region = Region.friendly.find(params[:region])
|
|
@cities = @cities.by_region(@current_region.id)
|
|
end
|
|
|
|
if params[:country]
|
|
@current_country = Country.friendly.find(params[:country])
|
|
@cities = @cities.by_country(@current_country.id)
|
|
end
|
|
|
|
@cities = @cities.page(params[:page]).per(10)
|
|
|
|
set_meta_tags(
|
|
title: @current_region ? "Cities in #{@current_region.name}" : "Explore Cities",
|
|
description: "Discover weather art for cities #{@current_region ? "in #{@current_region.name}" : 'worldwide'}. Real-time AI-generated weather visualization.",
|
|
keywords: "#{@current_region&.name}, cities, weather art, AI visualization"
|
|
)
|
|
end
|
|
|
|
def show
|
|
@city = City.friendly.find(params[:id])
|
|
ahoy.track "View City", {
|
|
city_id: @city.id,
|
|
name: @city.name,
|
|
event_type: 'city_view'
|
|
}
|
|
|
|
set_meta_tags(
|
|
title: @city.name,
|
|
description: "Experience #{@city.name}'s weather through AI-generated art. Daily updates of weather conditions visualized through artificial intelligence.",
|
|
keywords: "#{@city.name}, #{@city.country.name}, weather art, AI visualization",
|
|
og: {
|
|
image: @city.latest_weather_art&.image&.attached? ? url_for(@city.latest_weather_art.image) : nil
|
|
}
|
|
)
|
|
end
|
|
end
|