FIX: grant first quote at the date post was created

Previously due to #b2dc65f9534ea date on the quoted_posts table could not
be trusted.

This changes it so we use the date on the actual post as the grant date.

Note: there is an edge case where you create a post and only add a quote
a week later. In this case the badge will not be awarded at the correct
time (it will display it was granted a week ago).
That said this is far more rare than the current situation.
This commit is contained in:
Sam Saffron
2019-04-03 16:41:52 +11:00
parent b2dc65f953
commit 1c57ae6657
2 changed files with 31 additions and 1 deletions

View File

@@ -23,7 +23,7 @@ SQL
SQL
FirstQuote = <<SQL
SELECT ids.user_id, q.post_id, q.created_at granted_at
SELECT ids.user_id, q.post_id, p3.created_at granted_at
FROM
(
SELECT p1.user_id, MIN(q1.id) id
@@ -34,6 +34,7 @@ SQL
GROUP BY p1.user_id
) ids
JOIN quoted_posts q ON q.id = ids.id
JOIN badge_posts p3 ON q.post_id = p3.id
SQL
FirstLink = <<SQL