nilox
(nilox)
6 בינואר, 2022, 1:39pm
1
Hey guys!
I’m currently learning coding and I’m wondering what is the schema or technique for read / unread posts in Discourse?
I’ve seen how SMF does it, through a combination of Mark Board Read, Mark All Read, and marked read when seen the last post… etc.
How does Discourse handle this?
Thanks! =)
לייק 1
merefield
(Robert)
6 בינואר, 2022, 2:16pm
2
It’s best to delve into the Source:
A platform for community discussion. Free, open, simple.
Topic read state (by user) is tracked by the TopicUser model?:
# frozen_string_literal: true
class TopicUser < ActiveRecord::Base
belongs_to :user
belongs_to :topic
# used for serialization
attr_accessor :post_action_data
scope :level,
lambda { |topic_id, level|
where(topic_id: topic_id).where(
"COALESCE(topic_users.notification_level, :regular) >= :level",
regular: TopicUser.notification_levels[:regular],
level: TopicUser.notification_levels[level],
)
}
scope :tracking, lambda { |topic_id| level(topic_id, :tracking) }
This file has been truncated. show original
(the data of which is stored in the Postgres DB).
You can interact with this on the rails console, from the discourse directory in dev, go rails c
then you can do something like TopicUser.first and look at the data …
לייק 1
nilox
(nilox)
7 בינואר, 2022, 9:57am
3
Sweet. I see the schema right down there thanks!
לייק 1