develop #3
@@ -48,21 +48,21 @@ class PagesController < ApplicationController
|
|||||||
# Revenue metrics for promoter
|
# Revenue metrics for promoter
|
||||||
@total_revenue = current_user.events
|
@total_revenue = current_user.events
|
||||||
.joins(:orders)
|
.joins(:orders)
|
||||||
.where(orders: { status: ['paid', 'completed'] })
|
.where(orders: { status: [ "paid", "completed" ] })
|
||||||
.sum('orders.total_amount_cents') / 100.0
|
.sum("orders.total_amount_cents") / 100.0
|
||||||
|
|
||||||
@total_tickets_sold = current_user.events
|
@total_tickets_sold = current_user.events
|
||||||
.joins(:tickets)
|
.joins(:tickets)
|
||||||
.where(tickets: { status: 'active' })
|
.where(tickets: { status: "active" })
|
||||||
.count
|
.count
|
||||||
|
|
||||||
@active_events_count = current_user.events.where(state: 'published').count
|
@active_events_count = current_user.events.where(state: "published").count
|
||||||
@draft_events_count = current_user.events.where(state: 'draft').count
|
@draft_events_count = current_user.events.where(state: "draft").count
|
||||||
|
|
||||||
# Recent orders for promoter events
|
# Recent orders for promoter events
|
||||||
@recent_orders = Order.joins(:event)
|
@recent_orders = Order.joins(:event)
|
||||||
.where(events: { user: current_user })
|
.where(events: { user: current_user })
|
||||||
.where(status: ['paid', 'completed'])
|
.where(status: [ "paid", "completed" ])
|
||||||
.includes(:event, :user, tickets: :ticket_type)
|
.includes(:event, :user, tickets: :ticket_type)
|
||||||
.order(created_at: :desc)
|
.order(created_at: :desc)
|
||||||
.limit(10)
|
.limit(10)
|
||||||
@@ -74,9 +74,9 @@ class PagesController < ApplicationController
|
|||||||
|
|
||||||
revenue = current_user.events
|
revenue = current_user.events
|
||||||
.joins(:orders)
|
.joins(:orders)
|
||||||
.where(orders: { status: ['paid', 'completed'] })
|
.where(orders: { status: [ "paid", "completed" ] })
|
||||||
.where(orders: { created_at: start_date..end_date })
|
.where(orders: { created_at: start_date..end_date })
|
||||||
.sum('orders.total_amount_cents') / 100.0
|
.sum("orders.total_amount_cents") / 100.0
|
||||||
|
|
||||||
{
|
{
|
||||||
month: start_date.strftime("%B %Y"),
|
month: start_date.strftime("%B %Y"),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Event model representing nightlife events and events
|
# Event model representing nightlife events and events
|
||||||
# Manages event details, location data, and publication state
|
# Manages event details, location data, and publication state
|
||||||
require 'net/http'
|
require "net/http"
|
||||||
require 'json'
|
require "json"
|
||||||
|
|
||||||
class Event < ApplicationRecord
|
class Event < ApplicationRecord
|
||||||
# Define states for Event lifecycle management
|
# Define states for Event lifecycle management
|
||||||
@@ -93,13 +93,13 @@ class Event < ApplicationRecord
|
|||||||
|
|
||||||
response = Net::HTTP.get_response(uri)
|
response = Net::HTTP.get_response(uri)
|
||||||
|
|
||||||
if response.code == '200'
|
if response.code == "200"
|
||||||
data = JSON.parse(response.body)
|
data = JSON.parse(response.body)
|
||||||
|
|
||||||
if data.any?
|
if data.any?
|
||||||
result = data.first
|
result = data.first
|
||||||
self.latitude = result['lat'].to_f.round(6)
|
self.latitude = result["lat"].to_f.round(6)
|
||||||
self.longitude = result['lon'].to_f.round(6)
|
self.longitude = result["lon"].to_f.round(6)
|
||||||
Rails.logger.info "Geocoded address '#{venue_address}' to coordinates: #{latitude}, #{longitude}"
|
Rails.logger.info "Geocoded address '#{venue_address}' to coordinates: #{latitude}, #{longitude}"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -146,16 +146,16 @@ class Event < ApplicationRecord
|
|||||||
|
|
||||||
# Common French cities with approximate coordinates
|
# Common French cities with approximate coordinates
|
||||||
french_cities = {
|
french_cities = {
|
||||||
'paris' => { lat: 48.8566, lng: 2.3522 },
|
"paris" => { lat: 48.8566, lng: 2.3522 },
|
||||||
'lyon' => { lat: 45.7640, lng: 4.8357 },
|
"lyon" => { lat: 45.7640, lng: 4.8357 },
|
||||||
'marseille' => { lat: 43.2965, lng: 5.3698 },
|
"marseille" => { lat: 43.2965, lng: 5.3698 },
|
||||||
'toulouse' => { lat: 43.6047, lng: 1.4442 },
|
"toulouse" => { lat: 43.6047, lng: 1.4442 },
|
||||||
'nice' => { lat: 43.7102, lng: 7.2620 },
|
"nice" => { lat: 43.7102, lng: 7.2620 },
|
||||||
'nantes' => { lat: 47.2184, lng: -1.5536 },
|
"nantes" => { lat: 47.2184, lng: -1.5536 },
|
||||||
'montpellier' => { lat: 43.6110, lng: 3.8767 },
|
"montpellier" => { lat: 43.6110, lng: 3.8767 },
|
||||||
'strasbourg' => { lat: 48.5734, lng: 7.7521 },
|
"strasbourg" => { lat: 48.5734, lng: 7.7521 },
|
||||||
'bordeaux' => { lat: 44.8378, lng: -0.5792 },
|
"bordeaux" => { lat: 44.8378, lng: -0.5792 },
|
||||||
'lille' => { lat: 50.6292, lng: 3.0573 }
|
"lille" => { lat: 50.6292, lng: 3.0573 }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if any known city is mentioned in the address
|
# Check if any known city is mentioned in the address
|
||||||
@@ -166,7 +166,7 @@ class Event < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Check for common country indicators
|
# Check for common country indicators
|
||||||
if address_lower.include?('france') || address_lower.include?('french')
|
if address_lower.include?("france") || address_lower.include?("french")
|
||||||
return { lat: 46.603354, lng: 1.888334 } # Center of France
|
return { lat: 46.603354, lng: 1.888334 } # Center of France
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user