Continuing the discussion from “Thanks for Contributing” Popup in Posts Appearing Even After Limit Passed?:
I have a question about this change. I feel like I’m missing something or misunderstanding how this is supposed to work when testing it.
My expectation is that the education banner should appear on the first few posts, with the number controlled by the educate_until_posts site setting. By default, that value is 2.
For testing, I changed it to 5 just to be extra safe. However, my test user only saw the education message once.
I also looked at the code:
As I understand it, the method first rules out personal messages and users who already have a record indicating that the education message has been shown. That part makes sense to me.
Then it determines whether the user is creating a topic or a reply and calculates the user’s total number of posts/topics.
The next part is what confuses me. If the total post count is lower than the configured limit, we create the record that prevents the education message from being shown again - and then display the message.
What am I missing here?
For example, if educate_until_posts is left at its default value of 2, I would expect the message to be shown for the user’s first two posts.
The user starts creating their very first post. It’s not a PM, and there is no existing UserHistory record yet, so the message is shown - that makes sense.
But why is the UserHistory record created immediately afterward? Wouldn’t that prevent the message from ever being shown again?
I would have expected something more like this:
count = @user.topic_count + @user.post_count
if count >= SiteSetting.educate_until_posts
UserHistory.create!(
action: UserHistory.actions[:notified_about_composer_education],
target_user_id: @user.id,
)
elsif count < SiteSetting.educate_until_posts
return (
But if this were actually a problem, I assume the tests related to that setting would have failed. Since the PR was merged, they apparently did not.
Can someone help me understand what I’m overlooking here?
