Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post events increasing post count #1695

Closed
jordanjay29 opened this issue Dec 11, 2018 · 8 comments
Closed

Post events increasing post count #1695

jordanjay29 opened this issue Dec 11, 2018 · 8 comments
Assignees
Labels
Milestone

Comments

@jordanjay29
Copy link
Contributor

Bug Report

Current Behavior
Post count increases by one for Post Events, counted after post is made following the post event. See this thread on discuss for more information and demonstration links.

Steps to Reproduce

  1. Check profile for post count
  2. Perform an action on a discussion that generates a Post Event
  3. Check profile, post count should reflect previous count
  4. Make a new reply
  5. Check profile, post count should reflect previous count + 2

Expected Behavior
In step 5, post count should only reflect previous count + 1, post events should not count

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

  • Flarum version: Beta 8.1
@dsevillamartin
Copy link
Member

The issue seems to be that comments_count includes all types of posts, not only comments.
Thus actions like renaming a discussion are included in the count.

https://github.com/flarum/core/blob/master/src/User/User.php#L756

@MichaelBelgium
Copy link

Honestly why is there comment_count and discussion_count while you can get the count from the relationships 🤔

@franzliedke
Copy link
Contributor

franzliedke commented Dec 12, 2018

Performance and DB load, basically. Sometimes a little bit of extra work when inserting pays off greatly when reading.

You just have to be extra careful to sync correctly when inserting, as this issue shows. 😉

@luceos

This comment has been minimized.

@tobyzerner
Copy link
Contributor

This should be an easy fix. Just change

$this->comment_count = $this->posts()->count();

to

$this->comment_count = $this->posts()->where('type', 'comment')->count();

@luceos luceos closed this as completed in 671fdec Dec 19, 2018
@franzliedke franzliedke added this to the 0.1.0-beta.9 milestone Dec 19, 2018
@franzliedke
Copy link
Contributor

What about is_private?

@tobyzerner
Copy link
Contributor

True, didn't think about that.

@tobyzerner tobyzerner reopened this Dec 19, 2018
@luceos
Copy link
Member

luceos commented Dec 20, 2018

What if we had a UserMeta collection/class that would be extensible. In addition the default values, like comment_count and discussion_count are retrieved while dispatching an event. That logic could re-use the same logic used with the Policies perhaps..

I'm not too fond of more complexity, but it might be interesting to be able to create such statistical meta information on models.

@luceos luceos modified the milestones: 0.1.0-beta.9, 0.1.0-beta.10 Mar 8, 2019
@luceos luceos self-assigned this Jul 12, 2019
@luceos luceos closed this as completed in c258658 Jul 28, 2019
wzdiyb pushed a commit to wzdiyb/core that referenced this issue Feb 16, 2020
wzdiyb pushed a commit to wzdiyb/core that referenced this issue Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants