]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix wrong reading time when apply filters
authorNicolas Lœuillet <nicolas@loeuillet.org>
Sun, 24 Apr 2016 18:24:23 +0000 (20:24 +0200)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Sun, 24 Apr 2016 18:24:23 +0000 (20:24 +0200)
src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php

index dcdb3ab72965b3bbcea8920e4384c8d39d342988..5c2216cf29cbca9f7a2deb3fdc4752244a4a898d 100644 (file)
@@ -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, [