Mercurial > hg > soundsoftware-site
annotate db/migrate/098_set_topic_authors_as_watchers.rb @ 1628:9c5f8e24dadc live tip
Quieten this cron script
author | Chris Cannam |
---|---|
date | Tue, 25 Aug 2020 11:38:49 +0100 |
parents | 513646585e45 |
children |
rev | line source |
---|---|
Chris@0 | 1 class SetTopicAuthorsAsWatchers < ActiveRecord::Migration |
Chris@0 | 2 def self.up |
Chris@0 | 3 # Sets active users who created/replied a topic as watchers of the topic |
Chris@0 | 4 # so that the new watch functionality at topic level doesn't affect notifications behaviour |
Chris@0 | 5 Message.connection.execute("INSERT INTO #{Watcher.table_name} (watchable_type, watchable_id, user_id)" + |
Chris@0 | 6 " SELECT DISTINCT 'Message', COALESCE(m.parent_id, m.id), m.author_id" + |
Chris@0 | 7 " FROM #{Message.table_name} m, #{User.table_name} u" + |
Chris@0 | 8 " WHERE m.author_id = u.id AND u.status = 1") |
Chris@0 | 9 end |
Chris@0 | 10 |
Chris@0 | 11 def self.down |
Chris@0 | 12 # Removes all message watchers |
Chris@0 | 13 Watcher.delete_all("watchable_type = 'Message'") |
Chris@0 | 14 end |
Chris@0 | 15 end |