Browse Source

Change Bug

pull/245/head
sylor_huang@126.com 5 years ago
parent
commit
d5e57da6d4
4 changed files with 11 additions and 5 deletions
  1. +1
    -1
      app/helpers/api_index_helper.rb
  2. +2
    -1
      app/models/concerns/watchable.rb
  3. +3
    -3
      app/services/memos_service.rb
  4. +5
    -0
      db/migrate/20201014080839_add_watchers_count_to_memos.rb

+ 1
- 1
app/helpers/api_index_helper.rb View File

@@ -132,7 +132,7 @@ module ApiIndexHelper
def set_children_sections(objects,is_detail)
children_sections_array = []
objects.find_each do |sec|
image = sec.attachments&.last
image = sec.image_attachment
s_section = {
id: sec.id,
title: sec.title


+ 2
- 1
app/models/concerns/watchable.rb View File

@@ -13,7 +13,8 @@ module Watchable
end
def watched_by?(user)
!!(user && self.watcher_user_ids && self.watcher_user_ids.detect {|uid| uid == user.id })
watcher_users.exists?(id: user.id)
# !!(user && self.watcher_user_ids && self.watcher_user_ids.detect {|uid| uid == user.id })
end
def watch!(watchable)


+ 3
- 3
app/services/memos_service.rb View File

@@ -477,9 +477,9 @@ class MemosService
set_msg = "您没有权限"
end

memos = Memo.field_for_list.includes(:praise_tread, :author).where(:root_id => nil).order("sticky=1 desc, #{s_order} desc").limit(15)
memo_list = memo_data memos
{status: set_status, message: set_msg, memo_list: memo_list}
# memos = Memo.field_for_list.includes(:praise_tread, :author, :forums).where(:root_id => nil).order("sticky=1 desc, #{s_order} desc").limit(15)
# memo_list = memo_data memos
{status: set_status, message: set_msg}

end



+ 5
- 0
db/migrate/20201014080839_add_watchers_count_to_memos.rb View File

@@ -0,0 +1,5 @@
class AddWatchersCountToMemos < ActiveRecord::Migration[5.2]
def change
add_column :memos, :watchers_count, :integer, default: 0
end
end

Loading…
Cancel
Save