Download the PHP package sizeg/yii2-newton-cool-ranking-behavior without Composer
On this page you can find all versions of the php package sizeg/yii2-newton-cool-ranking-behavior. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sizeg/yii2-newton-cool-ranking-behavior
More information about sizeg/yii2-newton-cool-ranking-behavior
Files in sizeg/yii2-newton-cool-ranking-behavior
Package yii2-newton-cool-ranking-behavior
Short Description Yii2 Newton cool ranking behavior
License MIT
Homepage https://github.com/sizeg/yii2-newton-cool-ranking-behavior
Informations about the package yii2-newton-cool-ranking-behavior
Yii2 Newton Cool Ranking Behavior
This behavior provides the algorithm of rank hotness with Newton's law of cooling explained by Evan Miller.
You can use it to rate comments or blog posts. Listing active discussion threads in an online forum.
Read this article Rank Hotness With Newton's Law of Cooling for more details.
Installation
Package is available on Packagist, you can install it using Composer.
Dependencies
- Yii2 (testing with 2.8, but should work with lower versions)
Basic usage
Create migration,
Add behavior to your ActiveRecord model,
By default the new model would have [[NewtonCoolRankingBehavior::$initial]] value and will cooling with [[NewtonCoolRankingBehavior::$coolingRate]].
When there is new activity on an model, you need update rank,
Sometimes you need one or more models to show in top for a few days, then you need to boost it.
Boost value will be received from model [[NewtonCoolRankingBehavior::$rankBoostAttribute]] field. If field doesn't exist, the value will be received from optional [[NewtonCoolRankingBehavior::$boost]] attribute.