X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mood.c;h=415e1702a75f038694b53393d8674c426b1314c6;hb=a37f31bbe4f1b2745ef0f617cff122a2c5f95078;hp=e026c960d5fd878cdca6350f3e74a40b85c338f8;hpb=58566e1535a0c47ce59570598885ccabc75891bf;p=paraslash.git diff --git a/mood.c b/mood.c index e026c960..415e1702 100644 --- a/mood.c +++ b/mood.c @@ -504,7 +504,7 @@ static long compute_dynamic_score(const struct osl_row *aft_row) static int add_afs_statistics(const struct osl_row *row) { - uint64_t n, x, s; + uint64_t n, x, s, q; struct afs_info afsi; int ret; @@ -514,14 +514,18 @@ static int add_afs_statistics(const struct osl_row *row) n = statistics.num; x = afsi.last_played; s = statistics.last_played_sum; - if (n > 0) - statistics.last_played_qd += (x - s / n) * (x - s / n) * n / (n + 1); + if (n > 0) { + q = (x > s / n)? x - s / n : s / n - x; + statistics.last_played_qd += q * q * n / (n + 1); + } statistics.last_played_sum += x; x = afsi.num_played; s = statistics.num_played_sum; - if (n > 0) - statistics.num_played_qd += (x - s / n) * (x - s / n) * n / (n + 1); + if (n > 0) { + q = (x > s / n)? x - s / n : s / n - x; + statistics.num_played_qd += q * q * n / (n + 1); + } statistics.num_played_sum += x; statistics.num++; return 1;