Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
fix rubocop offense to use SQL.squish for HEREDOC
Browse files Browse the repository at this point in the history
  • Loading branch information
lxxxvi committed Sep 14, 2020
1 parent ac24ce8 commit f57f25d
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions app/services/cached_facts_table_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def drop_facts_table_sql
end

def ordered_list_of_keys_sql
<<~SQL
<<~SQL.squish
SELECT DISTINCT
f.key AS key
FROM facts f
Expand All @@ -64,7 +64,7 @@ def ordered_list_of_keys_sql
end

def create_temporary_table_sql
<<~SQL
<<~SQL.squish
CREATE TEMPORARY TABLE #{temporary_table_name}
AS
WITH
Expand Down Expand Up @@ -114,7 +114,7 @@ def create_temporary_table_sql
end

def create_facts_table_sql
<<~SQL
<<~SQL.squish
CREATE TABLE #{cached_facts_table_name}
AS
WITH
Expand Down Expand Up @@ -145,7 +145,7 @@ def create_facts_table_sql
end

def add_index_on_foreign_key_sql
<<~SQL
<<~SQL.squish
CREATE INDEX #{index_name}
ON #{cached_facts_table_name}
(
Expand Down
4 changes: 2 additions & 2 deletions app/services/cleaned_broadcasts_table_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def drop_table_sql
end

def create_table_sql
<<~SQL
<<~SQL.squish
CREATE TABLE #{table_name}
AS
WITH broadcasts_with_previous AS (
Expand Down Expand Up @@ -63,7 +63,7 @@ def create_table_sql
end

def add_index_on_foreign_key_sql
<<~SQL
<<~SQL.squish
CREATE INDEX index_broadcast_id_on_#{table_name}
ON #{table_name}
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
WITH artists_with_multiple_broadcasts_facts AS (
SELECT station_id AS station_id
, factable_type AS factable_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
SELECT b.station_id AS station_id
, s.artist_id AS factable_id
, min(broadcasted_at) AS value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
SELECT b.station_id AS station_id
, s.artist_id AS factable_id
, max(broadcasted_at) AS value
Expand Down
2 changes: 1 addition & 1 deletion app/services/facts/artist/total_broadcasts_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
SELECT b.station_id AS station_id
, s.artist_id AS factable_id
, count(*) AS value
Expand Down
2 changes: 1 addition & 1 deletion app/services/facts/calculator_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def execute(sql_statement)
end

def upsert_statement_sql
<<~SQL
<<~SQL.squish
WITH
static_data AS (
SELECT '#{factable_type}' AS factable_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
WITH songs_with_multiple_broadcasts_facts AS (
SELECT station_id AS station_id
, factable_type AS factable_type
Expand Down
2 changes: 1 addition & 1 deletion app/services/facts/song/first_broadcasted_at_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
SELECT station_id AS station_id
, song_id AS factable_id
, min(broadcasted_at) AS value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
SELECT station_id AS station_id
, song_id AS factable_id
, max(broadcasted_at) AS value
Expand Down
2 changes: 1 addition & 1 deletion app/services/facts/song/total_broadcasts_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
SELECT station_id AS station_id
, song_id AS factable_id
, count(1) AS value
Expand Down
2 changes: 1 addition & 1 deletion app/services/facts/station/total_broadcasts_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def factable_type
end

def calculated_data_sql
<<~SQL
<<~SQL.squish
SELECT station_id AS station_id
, station_id AS factable_id
, count(*) AS value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def up
private

def migration_sql
<<~SQL
<<~SQL.squish
UPDATE songs
SET ch_charts_scraper_status = 'new'
, ch_charts_scraper_status_updated_at = NOW()
Expand Down

0 comments on commit f57f25d

Please sign in to comment.