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

Implemented reputationPoints flow. #643

Conversation

EnesBaserr
Copy link
Contributor

📋 Proposed Changes

  • Implemented reputationPoints flow.

Related Issue

Closes #642

🧪 Included Tests

Calculation will be based on this.

public Long calculateReputation(User user) {
        List<Question> questions = questionRepository.findByAuthorId(user.getId());
        long questionCount = questions.size();
        Long questionUpvoteCount = questions.stream().map(Question::getUpvoteCount).reduce(0L, Long::sum);
        Long questionDownvoteCount = questions.stream().map(Question::getDownvoteCount).reduce(0L, Long::sum);
        List< Answer> answers= answerRepository.findByAnsweredBy(user.getId());
        long answerCount =  answers.size();
        Long answerUpvoteCount = answers.stream().map(Answer::getUpvoteCount).reduce(0L, Long::sum);
        Long answerDownvoteCount = answers.stream().map(Answer::getDownvoteCount).reduce(0L, Long::sum);
        return (questionCount * 10 + answerCount * 15 + questionUpvoteCount * 25 + answerUpvoteCount * 30) - (questionDownvoteCount*10 + answerDownvoteCount*15);

    }

@EnesBaserr EnesBaserr added the component: backend About backend label Dec 8, 2024
@EnesBaserr EnesBaserr requested a review from mmtftr December 8, 2024 19:27
@EnesBaserr EnesBaserr linked an issue Dec 8, 2024 that may be closed by this pull request
1 task
@EnesBaserr EnesBaserr self-assigned this Dec 8, 2024
@mmtftr
Copy link
Contributor

mmtftr commented Dec 8, 2024

According to our requirements,

Reputation Points: Reputation Points is a number associated with a Profile, defined as the sum of Ratings of the Profile Owner’s Questions and Answers.

This PR weighs upvotes more than downvotes. Can we instead weigh them the same so that one upvote cancels one downvote and vice versa?

@EnesBaserr
Copy link
Contributor Author

According to our requirements,

Reputation Points: Reputation Points is a number associated with a Profile, defined as the sum of Ratings of the Profile Owner’s Questions and Answers.

This PR weighs upvotes more than downvotes. Can we instead weigh them the same so that one upvote cancels one downvote and vice versa?

Resolved with last commit. Can you please check it

@mmtftr
Copy link
Contributor

mmtftr commented Dec 8, 2024

Thanks, good for merge

@EnesBaserr EnesBaserr merged commit 5f0396f into develop Dec 8, 2024
1 check passed
@EnesBaserr EnesBaserr deleted the backend/feature/642-backend-implement-reputation-point-feature branch December 8, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: backend About backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Backend] Implement Reputation Point Feature
2 participants