Fix wrong reading time when apply filters

This commit is contained in:
Nicolas Lœuillet 2016-04-24 20:24:23 +02:00
parent f97653c895
commit d8f8a59010
No known key found for this signature in database
GPG key ID: 5656BE27E1E34D0A

View 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, [