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

Add Power to Reactions #26

Closed
antonkomarev opened this issue Oct 10, 2018 · 11 comments
Closed

Add Power to Reactions #26

antonkomarev opened this issue Oct 10, 2018 · 11 comments

Comments

@antonkomarev
Copy link
Member

antonkomarev commented Oct 10, 2018

Possible names:

  • Reaction Power
  • Reaction Rate
  • Reaction Force
  • Reaction Strength

Case 1

Allow Reacter to react to Reactant with same reaction type more than once.

Example:
In social news application user Jane can vote up article up to 5 times.

Similar to Medium's Claps:

Case 2

Reacter has some kind of authority inside of the application and his reactions should have more weight among others.

Example:
In Question & Answer application user Jane solved more than 1000 questions. Jane's reactions will have more power now.

Additionally by this way it will be easier segregate reactions from more notable application users.

@antonkomarev antonkomarev added this to the v7.0 milestone Oct 10, 2018
@BenQoder
Copy link

BenQoder commented May 8, 2019

Any Update On This?

@antonkomarev
Copy link
Member Author

No. Haven't designed it yet. Not sure it will be done in near future because I'm hardly working on another free open source secret project.
Feel free to discuss this feature and propose implementations in PR. Any kind of help speeds up development process.

@antonkomarev
Copy link
Member Author

antonkomarev commented Jul 14, 2019

With reaction power Reaction model getWeight method should possibly return weight of reaction type multiplied on power instead of just proxying a weight of reaction type.

$reactionType = ReactionType::create([
    'name' => 'Love',
    'weight' => 2,
]);
$power = 3;

$reacter->reactTo($reactant, $reactionType, 3);

$reaction = Reaction::query()
    ->where('reactant_id', $reactant->getId())
    ->where('reacter_id', $reacter->getId())
    ->where('reaction_type_id', $reactionType->getId())
    ->first();

echo $reaction->getWeight(); // 6

I'm not sure that 5 likes with power of 2 are equal to 2 likes with power of 5. With this concept - both of them will produce weight equal to 10, but in fact one person will be able to overrate many people with just one powered like.

@antonkomarev
Copy link
Member Author

antonkomarev commented Jul 14, 2019

What is a default value of reaction power in all applications which are not using this feature?

1 or null?

// TODO: Make a research

@antonkomarev
Copy link
Member Author

antonkomarev commented Jul 16, 2019

Need to work with Mutually Exclusive Reactions #75

@BenQoder
Copy link

With reaction power Reaction model getWeight method should possibly return weight of reaction type multiplied on power instead of just proxying a weight of reaction type.

$reactionType = ReactionType::create([
    'name' => 'Love',
    'weight' => 2,
]);
$power = 3;

$reacter->reactTo($reactant, $reactionType, 3);

$reaction = Reaction::query()
    ->where('reactant_id', $reactant->getId())
    ->where('reacter_id', $reacter->getId())
    ->where('reaction_type_id', $reactionType->getId())
    ->first();

echo $reaction->getWeight(); // 6

I'm not sure that 5 likes with power of 2 are equal to 2 likes with power of 5. With this concept - both of them will produce weight equal to 10, but in fact one person will be able to overrate many people with just one powered like.

Thanks A Lot For Considering This.
You Are Also On The Right Track.
5 likes with the power of 2 is equal to 2 likes with the power of 5 which both case equals 10.
And The Default Power Should Be 1 In Other Applications

@antonkomarev
Copy link
Member Author

Default power value 1 gives ability to quick start using Power whenever you want without any future database changes.

@antonkomarev
Copy link
Member Author

antonkomarev commented Jul 16, 2019

Another one concept how Reaction Power could be used:

Proactive active users will have more power on their reactions.

Based on activity user will be placed in different reaction power tiers:

  • Average reaction power: the default power that every user starts with.
  • High reaction power: an active contributor, with a fair share of shares, upvotes & comments, etc.
  • Poor reaction power: user with very low rating (big amount of downvotes).

In Question & Answer application user Jane solved more than 1000 questions. Jane reactions could have more power now.

Additionally by this way it will be easier segregate reactions from more notable application users.

@antonkomarev
Copy link
Member Author

antonkomarev commented Jul 25, 2019

One more thing to consider. When reacter created a reaction with power=2 and want to increase\decrease power, how should we do it?

There is no way (via user interface) on Medium to decrease claps count by custom amount. You can only remove all of your post claps and create them again. For example if you clapped on post 7 times - Undo applause for this post button will post claps=-7. But you are able to add claps by clicking on them multiple times. Each time it sends claps amount which was added with this click (hold). If user clapped 3 times and added 4 claps more in total he will see 7 claps added but in request he will send claps=4.

I'm not sure that I like Medium implementation because if there will be need to limit power count from one user - we will need to fetch reaction on validation layer to sum current power count with added power and check if reaction power limit was reached.

Variant 1

unreactTo Reactant and reactTo it again with new power value.

Pros

  • Easy to implement

Cons

  • Reaction models spam. Since power could be added multiple times - each time we will delete and re-create reaction models.

Variant 2

In reactTo method get exact reaction instead just checking for hasReactedTo value and if power attribute differs - update its value.

Pros

  • No reactions models spam

Cons

  • More complicated implementation of reactTo method
  • Slower reactTo method

Variant 3

Add changePower method to Reaction model.

Pros

Cons

@antonkomarev
Copy link
Member Author

This feature was redesigned to new Weighted Reaction System in #85

@antonkomarev
Copy link
Member Author

antonkomarev commented Jul 31, 2019

I'm closing this issue. Core logic was implemented in #91 and available in dev-master branch.

It will be released with Laravel Love v8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants