nilox
(nilox)
January 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 Like
It’s best to delve into the Source:
A platform for community discussion. Free, open, simple. - GitHub - discourse/discourse: 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
self.ignored_columns = [
:highest_seen_post_number # Remove after 01 Jan 2022
]
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])
}
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 Like
nilox
(nilox)
January 7, 2022, 9:57am
3
Sweet. I see the schema right down there thanks!
1 Like