Skip to content

Statistics

Christian R edited this page Jan 24, 2023 · 7 revisions

Introduction

This page gives an overview of the statistics implemented in app/helpers/statistics_helper.rb. They can be used in the controllers with helper.FUNCTION_NAME.

Item popularity

Definition

The item popularity ( $p$ ) is a measure for the popularity of an item (obviously). It consists of the following values:

  • the total number the item was lent ( $n$ )
    • This reflects how popular the item was in the past.
  • the average lending duration ( $\bar{t}$ )
    • Items can be lent for a very long time by the same person. This should also increase the popularity especially because it lowers the total number the item could be lent in the past.
  • the amount of people on the waitlist ( $w$ )
    • While the first two components reflect the past, the length of the waitlist represents the current popularity.
  • the age of the item ( $a$ )
    • The age normalizes the first two values.

The item popularity is computed by this formula:

$$ p = \frac{(n+1)\cdot(\bar{t}+1)\cdot (w+1)}{max(a,1)} $$

All factors in the numerator are increased by $1$ so that the popularity can not drop to zero if one factor is zero.

Usage

It can be used by calling helpers.statistics_item_popularity.

Sorting by popularity

Lists of items can be sorted by calling helpers.statistics_sort_items_by_popularity. It takes an item list and returns the sorted item list. It takes an optional parameter order to specify the sort order by passing either :asc or :desc.

Clone this wiki locally