DEV: attempts to fix indentation
This commit is contained in:
parent
541fd12823
commit
4a167a7f5a
|
@ -497,53 +497,53 @@ class Queries
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
queries["top-tags-per-year"]["sql"] = <<~SQL
|
queries["top-tags-per-year"]["sql"] = <<~SQL
|
||||||
-- [params]
|
-- [params]
|
||||||
-- integer :rank_max = 5
|
-- integer :rank_max = 5
|
||||||
|
|
||||||
WITH data AS (SELECT
|
WITH data AS (SELECT
|
||||||
tag_id,
|
tag_id,
|
||||||
EXTRACT(YEAR FROM created_at) AS year
|
EXTRACT(YEAR FROM created_at) AS year
|
||||||
FROM topic_tags)
|
FROM topic_tags)
|
||||||
|
|
||||||
SELECT year, rank, name, qt FROM (
|
SELECT year, rank, name, qt FROM (
|
||||||
SELECT
|
SELECT
|
||||||
tag_id,
|
tag_id,
|
||||||
COUNT(tag_id) AS qt,
|
COUNT(tag_id) AS qt,
|
||||||
year,
|
year,
|
||||||
rank() OVER (PARTITION BY year ORDER BY COUNT(tag_id) DESC) AS rank
|
rank() OVER (PARTITION BY year ORDER BY COUNT(tag_id) DESC) AS rank
|
||||||
FROM
|
FROM
|
||||||
data
|
data
|
||||||
GROUP BY year, tag_id) as rnk
|
GROUP BY year, tag_id) as rnk
|
||||||
INNER JOIN tags ON tags.id = rnk.tag_id
|
INNER JOIN tags ON tags.id = rnk.tag_id
|
||||||
WHERE rank <= :rank_max
|
WHERE rank <= :rank_max
|
||||||
ORDER BY year DESC, qt DESC
|
ORDER BY year DESC, qt DESC
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
queries["number_of_replies_by_category"]["sql"] = <<~SQL
|
queries["number_of_replies_by_category"]["sql"] = <<~SQL
|
||||||
-- [params]
|
-- [params]
|
||||||
-- boolean :enable_null_category = false
|
-- boolean :enable_null_category = false
|
||||||
|
|
||||||
WITH post AS (SELECT
|
WITH post AS (SELECT
|
||||||
id AS post_id,
|
id AS post_id,
|
||||||
topic_id,
|
topic_id,
|
||||||
EXTRACT(YEAR FROM created_at) AS year
|
EXTRACT(YEAR FROM created_at) AS year
|
||||||
FROM posts
|
FROM posts
|
||||||
WHERE post_type = 1
|
WHERE post_type = 1
|
||||||
AND deleted_at ISNULL
|
AND deleted_at ISNULL
|
||||||
AND post_number != 1)
|
AND post_number != 1)
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
p.year,
|
p.year,
|
||||||
t.category_id AS id,
|
t.category_id AS id,
|
||||||
c.name category,
|
c.name category,
|
||||||
COUNT(p.post_id) AS qt
|
COUNT(p.post_id) AS qt
|
||||||
FROM post p
|
FROM post p
|
||||||
INNER JOIN topics t ON t.id = p.topic_id
|
INNER JOIN topics t ON t.id = p.topic_id
|
||||||
LEFT JOIN categories c ON c.id = t.category_id
|
LEFT JOIN categories c ON c.id = t.category_id
|
||||||
WHERE t.deleted_at ISNULL
|
WHERE t.deleted_at ISNULL
|
||||||
AND (:enable_null_category = true OR t.category_id NOTNULL)
|
AND (:enable_null_category = true OR t.category_id NOTNULL)
|
||||||
GROUP BY t.category_id, c.name, p.year
|
GROUP BY t.category_id, c.name, p.year
|
||||||
ORDER BY p.year DESC, qt DESC
|
ORDER BY p.year DESC, qt DESC
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
# convert query ids from "mostcommonlikers" to "-1", "mostmessages" to "-2" etc.
|
# convert query ids from "mostcommonlikers" to "-1", "mostmessages" to "-2" etc.
|
||||||
|
|
Loading…
Reference in New Issue