chore: clean up trailing whitespace and formatting
- Removed unnecessary leading and trailing blank lines in several ActiveAdmin register files. - Reformatted string delimiters for consistency, changing single quotes to double quotes in tracking events in the Cities and WeatherArts controllers. - Ensured proper spacing in array definitions across several models, including Ahoy::Event and Ahoy::Visit. These changes improve code readability and maintain consistency throughout the codebase by ensuring uniform use of quotes and removing excess whitespace.
This commit is contained in:
parent
dd6cd0451d
commit
50321533f7
@ -1,5 +1,4 @@
|
|||||||
ActiveAdmin.register Ahoy::Event do
|
ActiveAdmin.register Ahoy::Event do
|
||||||
|
|
||||||
# See permitted parameters documentation:
|
# See permitted parameters documentation:
|
||||||
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
||||||
#
|
#
|
||||||
@ -29,5 +28,4 @@ ActiveAdmin.register Ahoy::Event do
|
|||||||
filter :name
|
filter :name
|
||||||
filter :time
|
filter :time
|
||||||
filter :properties
|
filter :properties
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
ActiveAdmin.register Ahoy::Visit do
|
ActiveAdmin.register Ahoy::Visit do
|
||||||
|
|
||||||
# See permitted parameters documentation:
|
# See permitted parameters documentation:
|
||||||
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
||||||
#
|
#
|
||||||
@ -33,5 +32,4 @@ ActiveAdmin.register Ahoy::Visit do
|
|||||||
filter :started_at
|
filter :started_at
|
||||||
filter :city
|
filter :city
|
||||||
filter :country
|
filter :country
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ class CitiesController < ApplicationController
|
|||||||
ahoy.track "View City", {
|
ahoy.track "View City", {
|
||||||
city_id: @city.id,
|
city_id: @city.id,
|
||||||
name: @city.name,
|
name: @city.name,
|
||||||
event_type: 'city_view'
|
event_type: "city_view"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_meta_tags(
|
set_meta_tags(
|
||||||
|
@ -6,12 +6,12 @@ class WeatherArtsController < ApplicationController
|
|||||||
ahoy.track "View Weather Art", {
|
ahoy.track "View Weather Art", {
|
||||||
weather_art_id: @weather_art.id,
|
weather_art_id: @weather_art.id,
|
||||||
city_id: @weather_art.city_id,
|
city_id: @weather_art.city_id,
|
||||||
event_type: 'weather_art_view'
|
event_type: "weather_art_view"
|
||||||
}
|
}
|
||||||
ahoy.track "View City", {
|
ahoy.track "View City", {
|
||||||
city_id: @city.id,
|
city_id: @city.id,
|
||||||
name: @city.name,
|
name: @city.name,
|
||||||
event_type: 'city_view'
|
event_type: "city_view"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_meta_tags(
|
set_meta_tags(
|
||||||
|
@ -22,7 +22,7 @@ class City < ApplicationRecord
|
|||||||
|
|
||||||
|
|
||||||
scope :by_popularity, -> {
|
scope :by_popularity, -> {
|
||||||
if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite'
|
if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite"
|
||||||
joins("LEFT JOIN ahoy_events ON json_extract(ahoy_events.properties, '$.city_id') = cities.id
|
joins("LEFT JOIN ahoy_events ON json_extract(ahoy_events.properties, '$.city_id') = cities.id
|
||||||
AND json_extract(ahoy_events.properties, '$.event_type') = 'city_view'")
|
AND json_extract(ahoy_events.properties, '$.event_type') = 'city_view'")
|
||||||
.group("cities.id")
|
.group("cities.id")
|
||||||
@ -87,7 +87,7 @@ class City < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def view_count
|
def view_count
|
||||||
if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite'
|
if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite"
|
||||||
Ahoy::Event.where("json_extract(properties, '$.event_type') = 'city_view' AND json_extract(properties, '$.city_id') = ?", self.id).count
|
Ahoy::Event.where("json_extract(properties, '$.event_type') = 'city_view' AND json_extract(properties, '$.city_id') = ?", self.id).count
|
||||||
else
|
else
|
||||||
Ahoy::Event.where("properties->>'event_type' = 'city_view' AND (properties->>'city_id')::integer = ?", self.id).count
|
Ahoy::Event.where("properties->>'event_type' = 'city_view' AND (properties->>'city_id')::integer = ?", self.id).count
|
||||||
|
@ -12,7 +12,7 @@ class WeatherArt < ApplicationRecord
|
|||||||
validates :city_id, presence: true
|
validates :city_id, presence: true
|
||||||
|
|
||||||
scope :by_popularity, -> {
|
scope :by_popularity, -> {
|
||||||
if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite'
|
if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite"
|
||||||
joins("LEFT JOIN ahoy_events ON json_extract(ahoy_events.properties, '$.weather_art_id') = weather_arts.id
|
joins("LEFT JOIN ahoy_events ON json_extract(ahoy_events.properties, '$.weather_art_id') = weather_arts.id
|
||||||
AND json_extract(ahoy_events.properties, '$.event_type') = 'weather_art_view'")
|
AND json_extract(ahoy_events.properties, '$.event_type') = 'weather_art_view'")
|
||||||
.group("weather_arts.id")
|
.group("weather_arts.id")
|
||||||
@ -44,7 +44,7 @@ class WeatherArt < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def view_count
|
def view_count
|
||||||
if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite'
|
if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite"
|
||||||
Ahoy::Event.where("json_extract(properties, '$.event_type') = 'weather_art_view' AND json_extract(properties, '$.weather_art_id') = ?", self.id).count
|
Ahoy::Event.where("json_extract(properties, '$.event_type') = 'weather_art_view' AND json_extract(properties, '$.weather_art_id') = ?", self.id).count
|
||||||
else
|
else
|
||||||
Ahoy::Event.where("properties->>'event_type' = 'weather_art_view' AND (properties->>'weather_art_id')::integer = ?", self.id).count
|
Ahoy::Event.where("properties->>'event_type' = 'weather_art_view' AND (properties->>'weather_art_id')::integer = ?", self.id).count
|
||||||
|
@ -14,13 +14,13 @@ class CleanAhoyDataWorker
|
|||||||
|
|
||||||
def cleanup_old_events
|
def cleanup_old_events
|
||||||
cutoff_date = 3.months.ago
|
cutoff_date = 3.months.ago
|
||||||
deleted_events_count = Ahoy::Event.where('time < ?', cutoff_date).delete_all
|
deleted_events_count = Ahoy::Event.where("time < ?", cutoff_date).delete_all
|
||||||
Rails.logger.info "Deleted #{deleted_events_count} old Ahoy events"
|
Rails.logger.info "Deleted #{deleted_events_count} old Ahoy events"
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_old_visits
|
def cleanup_old_visits
|
||||||
cutoff_date = 3.months.ago
|
cutoff_date = 3.months.ago
|
||||||
deleted_visits_count = Ahoy::Visit.where('started_at < ?', cutoff_date).delete_all
|
deleted_visits_count = Ahoy::Visit.where("started_at < ?", cutoff_date).delete_all
|
||||||
Rails.logger.info "Deleted #{deleted_visits_count} old Ahoy visits"
|
Rails.logger.info "Deleted #{deleted_visits_count} old Ahoy visits"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user