1 stable release
Uses old Rust 2015
1.0.1 | Apr 18, 2017 |
---|
#4 in #kinda
3KB
hot-ranking-algorithm-rs
Algorithm that measures how relevant a given data set is, kinda like Reddit.
Doesn't do any jitter stuff and can probably be gamed if you try hard enough, but it should be useful enough if you want to wire up community-driven news site that always has fresh, relevant content for people to discover.
Usage
extern crate hot_ranking_algorithm;
extern crate time;
use hot-ranking-algorithm::rank;
let epoch = time::now_utc();
let timestamp = time::now_utc();
let upvotes = 3;
let downvotes = 1;
let ranking = rank(upvotes, downvotes, timestamp, epoch);
println!('{}', ranking);
// => 2
API
rank(upvotes: &i32, downvotes: &i32, timestamp: &SteadyTime, epoch: &SteadyTime) -> result: i32
Calculate the relevancy of an item based on upvotes, downvotes, a current timestamp and the epoch at which the program is first run (e.g. no value can be lower than that).
Installation
$ cargo add hot-ranking-algorithm
See Also
License
Dependencies
~8.5MB
~212K SLoC