From: Nicolas LÅ“uillet Date: Sun, 24 Apr 2016 18:24:23 +0000 (+0200) Subject: Fix wrong reading time when apply filters X-Git-Tag: 2.0.4~13^2~2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=d8f8a5901086f243f9fa215d52baea6833e1cb55;p=github%2Fwallabag%2Fwallabag.git Fix wrong reading time when apply filters --- diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index dcdb3ab7..5c2216cf 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -35,6 +35,16 @@ class EntryFilterType extends AbstractType { $builder ->add('readingTime', NumberRangeFilterType::class, [ + 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { + $value = $values['value']; + + $min = (int) ($value['left_number'][0] * $this->user->getConfig()->getReadingSpeed()); + $max = (int) ($value['right_number'][0] * $this->user->getConfig()->getReadingSpeed()); + + $expression = $filterQuery->getExpr()->between($field, $min, $max); + + return $filterQuery->createCondition($expression); + }, 'label' => 'entry.filters.reading_time.label', ]) ->add('createdAt', DateRangeFilterType::class, [