Add unstarred_at column to topic_users so we can permanently track when topics are starred

This commit is contained in:
Neil Lalonde
2013-04-28 16:58:14 -04:00
parent 60208e3ded
commit dc07563c0d
3 changed files with 40 additions and 22 deletions

View File

@ -569,7 +569,7 @@ class Topic < ActiveRecord::Base
# Enable/disable the star on the topic
def toggle_star(user, starred)
Topic.transaction do
TopicUser.change(user, id, starred: starred, starred_at: starred ? DateTime.now : nil)
TopicUser.change(user, id, {starred: starred}.merge( starred ? {starred_at: DateTime.now, unstarred_at: nil} : {unstarred_at: DateTime.now}))
# Update the star count
exec_sql "UPDATE topics