Add the Popularity metric

PR #20180.
This commit is contained in:
Aliaksei Urbanski
2024-04-01 21:23:08 +03:00
committed by GitHub
parent 8e6515be2c
commit f37d0c486c
15 changed files with 93 additions and 0 deletions

View File

@@ -1545,6 +1545,15 @@ qlonglong TorrentImpl::nextAnnounce() const
return lt::total_seconds(m_nativeStatus.next_announce);
}
qreal TorrentImpl::popularity() const
{
// in order to produce floating-point numbers using `std::chrono::duration_cast`,
// we should use `qreal` as `Rep` to define the `months` duration
using months = std::chrono::duration<qreal, std::chrono::months::period>;
const auto activeMonths = std::chrono::duration_cast<months>(m_nativeStatus.active_duration).count();
return (activeMonths > 0) ? (realRatio() / activeMonths) : 0;
}
void TorrentImpl::setName(const QString &name)
{
if (m_name != name)