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

Penalize less for age #198

Merged
merged 3 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
{#if $event}
<main class="mx-auto my-4 max-w-4xl px-4">
<List />
<div class="mt-4 text-center text-slate-400">
Questions are ordered by <a
class="hover:text-black"
href="https://www.evanmiller.org/ranking-news-items-with-upvotes.html">votes over time</a
>.
</div>
<div class="mt-4 text-center text-slate-400">
( made on <a class="hover:text-black" href="https://github.com/jonhoo/wewerewondering"
>github</a
Expand Down
11 changes: 10 additions & 1 deletion server/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,19 @@ async fn list_inner(
)
.unwrap_or(Duration::ZERO)
.as_secs()
// in minutes so questions don't jump around quite as much
/ 60;
// +1 so that first minute questions don't get inf scores (for the ln)
let dt = dt_in_minutes_rounded_down + 1;
// +1 again to avoid NaN scores for first-minute questions (for / (1 - e^0)).
let dt = dt + 1;
// ln so that stories get less penalized for age over time
// after all, this is Q&A, not minute-to-minute hot news
let dt = (dt as f64).ln();
let votes = q["votes"].as_u64().expect("votes is a number") as f64;
let exp = (-1. * dt as f64).exp();
// max so that even if vote count somehow got to 0, count it as 1
let votes = votes.max(1.);
let exp = (-1. * dt as f64).exp_m1() + 1.;
Score(exp * votes / (1. - exp))
};
questions.sort_by_cached_key(|q| std::cmp::Reverse(score(q)));
Expand Down
Loading