Skip to content

Commit

Permalink
Add a description to a freshness_rank function's formula
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Nov 1, 2022
1 parent 0b25a9b commit 67f9aad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/tribler/core/utilities/search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,14 @@ def freshness_rank(freshness: Optional[float] = 0) -> float:
"""
freshness = max(0, freshness or 0)
if not freshness:
return 0

return 0 # for freshness <= 0 the rank value is 0 because of an incorrect freshness value

# The function declines from 1.0 to 0.0 on range (0..Infinity], with the following properties:
# * for just created torrents the rank value is close to 1.0
# * for 30-days old torrents the rank value is 0.5
# * for very old torrens the rank value is going to zero
# It was possible to use another formulas with the same properties (for example, exponent-based),
# the exact curve shape is not really important.
days = (freshness or 0) / SECONDS_IN_DAY
return 1 / (1 + days / 30)

Expand Down

0 comments on commit 67f9aad

Please sign in to comment.