From d8f8a5901086f243f9fa215d52baea6833e1cb55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Sun, 24 Apr 2016 20:24:23 +0200 Subject: [PATCH] Fix wrong reading time when apply filters --- src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | 10 ++++++++++ 1 file changed, 10 insertions(+) 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, [ -- 2.41.0