| @@ -132,7 +132,7 @@ module ApiIndexHelper | |||||
| def set_children_sections(objects,is_detail) | def set_children_sections(objects,is_detail) | ||||
| children_sections_array = [] | children_sections_array = [] | ||||
| objects.find_each do |sec| | objects.find_each do |sec| | ||||
| image = sec.attachments&.last | |||||
| image = sec.image_attachment | |||||
| s_section = { | s_section = { | ||||
| id: sec.id, | id: sec.id, | ||||
| title: sec.title | title: sec.title | ||||
| @@ -13,7 +13,8 @@ module Watchable | |||||
| end | end | ||||
| def watched_by?(user) | 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 | end | ||||
| def watch!(watchable) | def watch!(watchable) | ||||
| @@ -477,9 +477,9 @@ class MemosService | |||||
| set_msg = "您没有权限" | set_msg = "您没有权限" | ||||
| end | 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 | end | ||||
| @@ -0,0 +1,5 @@ | |||||
| class AddWatchersCountToMemos < ActiveRecord::Migration[5.2] | |||||
| def change | |||||
| add_column :memos, :watchers_count, :integer, default: 0 | |||||
| end | |||||
| end | |||||