Where are staff notices stored in the database?

AI-generated summary

The discussion revolves around locating staff notices in the Discourse database. j127 is trying to query staff notices, specifically a recent custom one, but is having trouble finding where they are stored. tgxworld suggests using PlugintStoreRow.where(plugin_name: "user_notes"), but j127 clarifies they are looking for “staff notices” (a core feature) rather than “user notes” (a plugin).

tgxworld points out that staff notices are stored in custom fields, referencing the Discourse GitHub repository. j127 shares a Rails console command to skim through the data, but ultimately doesn’t find the custom text they were looking for, suggesting the staff notice they sought isn’t live.

Does anyone know how to query staff notes notices from the database? I’ve been looking around in the code but haven’t been able to find where they are stored.

My main goal is to find a specific staff notice that was written in the past week, so I’m looking for a way to skim through the recent custom ones.

Edit: I was having trouble, because I was looking for “staff notes”. I’ve just found a custom_field that might be what I’m looking for, but I’m not sure how to list all the staff notices with custom text.

pry(main)> p.custom_fields
=> {"notice_type"=>"new_user"}

PlugintStoreRow.where(plugin_name: "user_notes") is probably what you’re looking for

Thanks, I’m looking for “staff notices” (core feature), which I think is different from “user notes” (separate plugin). I might be confused though. :slight_smile:

The item named “Add Staff Notice”:

It should be in the custom fields like you’ve mentioned

Thanks. In case anyone else is looking for a quick way to skim the data, this works in the Rails console:

results = Post.all.reject { |p| p.custom_fields['notice_type'].nil? }

results.each do |r|
  puts r.custom_fields
end

Sample output:

{"notice_type"=>"returning_user", "notice_args"=>"2018-08-04T07:43:52Z"}
{"notice_type"=>"new_user"}
{"notice_type"=>"new_user"}
{"notice_type"=>"new_user"}
{"notice_type"=>"returning_user", "notice_args"=>"2016-10-11T09:32:30Z"}
{"notice_type"=>"returning_user", "notice_args"=>"2014-04-02T16:16:04Z"}
{"notice_type"=>"new_user"}
{"notice_type"=>"new_user"}

I don’t see any custom text there, so I guess the staff notice I was looking for isn’t live.