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

[Bug]: person_view.counts.post_score and .comment_score don't match the total post/comment scores #3393

Closed
4 tasks done
Dakkaron opened this issue Jun 28, 2023 · 9 comments
Closed
4 tasks done
Labels
area: api bug Something isn't working

Comments

@Dakkaron
Copy link

Dakkaron commented Jun 28, 2023

Requirements

  • Is this a bug report? For questions or discussions use https://lemmy.ml/c/lemmy_support
  • Did you check to see if this issue already exists?
  • Is this only a single bug? Do not put multiple bugs in one issue.
  • Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.

Summary

When doing an a REST call to /api/v3/user?username=someuser, I get something like this:

'person_view': {
   'counts': {
     'id': ...,
     'person_id': ...,
     'post_count': 14,
     'post_score': 448,
     'comment_count': 321,
     'comment_score': 71
   }

I checked these value against the total score of all my posts and comments, and while the count is correct, the score is not.

The post score is off by ~20%, but the real comment score is more than 20x of what this endpoint reports.

Steps to Reproduce

  1. Do a REST call to /api/v3/user?username=[someuser]
  2. Compare the total scores with the sum of the scores of all posts/comments of that user

Technical Details

I got the scores of all posts/comments using the same endpoint and the pagination to fetch all comments.

Here's a Python (3.6+) snippet to demonstrate the issue:

import requests
import math

INSTANCE_URL = "https://feddit.de"
TARGET_USER = "ENTER_USER_NAME_HERE"

LIMIT_PER_PAGE = 50

l = Lemmy(INSTANCE_URL)

res = requests.get(f"{INSTANCE_URL}/api/v3/user?username={TARGET_USER}&limit={LIMIT_PER_PAGE}").json()

totalPostScore = 0
totalCommentScore = 0
page = 1
while len(res["posts"])+len(res["comments"]) > 0:
	totalPostScore += sum([ x["counts"]["score"] for x in res["posts"] ])
	totalCommentScore += sum([ x["counts"]["score"] for x in res["comments"] ])
	
	page += 1
	res = requests.get(f"{INSTANCE_URL}/api/v3/user?username={TARGET_USER}&limit={LIMIT_PER_PAGE}&page={page}").json()

print("Post score from API:      ", res["person_view"]["counts"]["post_score"])
print("Calculated post score:    ", totalPostScore)
print("Comment score from API:   ", res["person_view"]["counts"]["comment_score"])
print("Calculated comment score: ", totalCommentScore)

Version

0.17.4

Lemmy Instance URL

https://feddit.de

@Dakkaron Dakkaron added the bug Something isn't working label Jun 28, 2023
@dropdevrahul
Copy link

Can i pick this up?

@Mubelotix
Copy link

See aeharding/voyager#312

@dessalines
Copy link
Member

Oh yeah we forgot to remove those karma scores from the API.

Also though I can think of a number of reasons why they would be off, because the triggers there are imperfect; people deleting comments, removing their accounts, etc.

@Nutomic
Copy link
Member

Nutomic commented Oct 24, 2023

These fields are used for person sort, so the calculation should be fixed and also fields marked as #[serde(skip)].

dessalines added a commit that referenced this issue Oct 24, 2023
dessalines added a commit that referenced this issue Oct 24, 2023
@aeharding
Copy link

Hello! Certain apps such as Voyager use these fields for user profiles. I understand the values aren't correct at the moment, but they work well enough. I also understand some people don't like showing "karma" for users, but some people do (and it's a helpful tool for modding).

Could these fields remain for apps that choose to show them?

image

@dessalines
Copy link
Member

Public karma counts and karma farming are one of the things we really don't want to replicate from reddit, there was a discussion about it for lemmy-ui, and it was decided to stop showing them because of how psychologically harmful it is.

We should've removed these a long time ago from the API. As a substitute, you can show the post_count and comment_count instead of those scores.

@aeharding
Copy link

@dessalines I see, thanks for the reply! I'll remove from Voyager then. Perhaps in the future, user scores could be exposed in CommentReportView (reporter + reportee) to help moderate?

@dessalines
Copy link
Member

No probs. I could see that potentially having value for mods (IE to find troll accounts with negative total scores), but also it looks like CommentView includes CommentAggregates, so the downvote counts for that comment are shown. Its probably not too necessary, as on should probably go into their history anyway, rather than just looking at a person's karma score.

@Nutomic
Copy link
Member

Nutomic commented Mar 15, 2024

These fields are now removed from the api.

@Nutomic Nutomic closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants