FIX: assign queries (#138)

In July, we introduced new Assignment table to discourse-assign plugin (https://github.com/discourse/discourse-assign/pull/169)

Assignment explorer queries had to be updated
This commit is contained in:
Krzysztof Kotlarek 2021-09-10 14:17:30 +10:00 committed by GitHub
parent 4dd803ba0c
commit 6ce092d969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 11 deletions

View File

@ -406,11 +406,11 @@ class Queries
SQL SQL
queries["assigned-topics-report"]["sql"] = <<~SQL queries["assigned-topics-report"]["sql"] = <<~SQL
SELECT value::int user_id, topic_id SELECT a.assigned_to_id user_id, a.topic_id
FROM topic_custom_fields tf FROM assignments a
JOIN topics t on t.id = topic_id JOIN topics t on t.id = a.topic_id
JOIN users u on u.id = value::int JOIN users u on u.id = a.assigned_to_id
WHERE tf.name = 'assigned_to_id' WHERE a.assigned_to_type = 'User'
AND t.deleted_at IS NULL AND t.deleted_at IS NULL
ORDER BY username, topic_id ORDER BY username, topic_id
SQL SQL
@ -459,14 +459,14 @@ class Queries
SQL SQL
queries["total-assigned-topics-report"]["sql"] = <<~SQL queries["total-assigned-topics-report"]["sql"] = <<~SQL
SELECT value::int user_id, SELECT a.assigned_to_id AS user_id,
count(*)::varchar || ',/u/' || username_lower || '/activity/assigned' assigned_url count(*)::varchar || ',/u/' || username_lower || '/activity/assigned' assigned_url
FROM topic_custom_fields tf FROM assignments a
JOIN topics t on t.id = topic_id JOIN topics t on t.id = a.topic_id
JOIN users u on u.id = value::int JOIN users u on u.id = a.assigned_to_id
WHERE tf.name = 'assigned_to_id' WHERE a.assigned_to_type = 'User'
AND t.deleted_at IS NULL AND t.deleted_at IS NULL
GROUP BY value::int, username_lower GROUP BY a.assigned_to_id, username_lower
ORDER BY count(*) DESC, username_lower ORDER BY count(*) DESC, username_lower
SQL SQL