style: improve whitespace in SQL join syntax

- Adjusted join statement in SQLite and PostgreSQL
- Ensure consistent use of whitespace for better readability

This change improves code clarity without changing any
query behavior, making it easier for future developers
to maintain and read the SQL join conditions.
This commit is contained in:
songtianlun 2025-02-13 13:16:06 +08:00
parent 5efe441fa8
commit eda20ecca5

View File

@ -42,14 +42,14 @@ class City < ApplicationRecord
# 根据数据库类型构建不同的查询
base_query = if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite"
joins(<<-SQL.squish)
LEFT JOIN ahoy_events ON
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 ahoy_events.time > '#{start_time}'
SQL
else
joins(<<-SQL.squish)
LEFT JOIN ahoy_events ON
LEFT JOIN ahoy_events ON#{' '}
(ahoy_events.properties::jsonb->>'city_id')::integer = cities.id
AND ahoy_events.properties::jsonb->>'event_type' = 'city_view'
AND ahoy_events.time > '#{start_time}'