Skip to content

wrong reputation computation #118

@lalitkaim

Description

@lalitkaim

In stackoverflow design in both Answer and Question class, in vote API voter's reputation should change instead author.

// Before
@OverRide
public void vote(User voter, VoteType type) {
votes.removeIf(v -> v.getVoter().equals(voter));
votes.add(new Vote(voter, type));
author.updateReputation(10 * (type == VoteType.UPVOTE ? 1 : -1)); // +10 for upvote, -10 for downvote
}

//After
@OverRide
public void vote(User voter, VoteType type) {
votes.removeIf(v -> v.getVoter().equals(voter));
votes.add(new Vote(voter, type));
voter.updateReputation(10 * (type == VoteType.UPVOTE ? 1 : -1)); // +10 for upvote, -10 for downvote
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions