More efficient query for watched_by? and use etag for the status
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
class Cards::WatchesController < ApplicationController
|
||||
include CardScoped
|
||||
|
||||
def show
|
||||
fresh_when etag: @card.watch_for(Current.user)
|
||||
end
|
||||
|
||||
def create
|
||||
@card.watch_by Current.user
|
||||
end
|
||||
|
||||
@@ -9,7 +9,11 @@ module Card::Watchable
|
||||
end
|
||||
|
||||
def watched_by?(user)
|
||||
watchers.include?(user)
|
||||
watch_for(user)&.watching?
|
||||
end
|
||||
|
||||
def watch_for(user)
|
||||
watches.find_by(user: user)
|
||||
end
|
||||
|
||||
def watch_by(user)
|
||||
|
||||
Reference in New Issue
Block a user