protected function addTimeConstraints($request, $query)
    {
        if ($request->query('from')) {
            $from = new \DateTime($request->query('from'));
            $until = new \DateTime();
        }

        if ($request->query('until')) {
            $until = new \DateTime($request->query('until'));
        }

        if (!empty($from)) {
            $query->where(function ($builder) use ($from, $until) {
                return $builder->between('@timestamp', $from->format('Y-m-d H:i:s'), $until->format('Y-m-d H:i:s'));
            });
            return;
        }

        if (!empty($until)) {
            $query->where(['@timestamp <=' => $until->format('Y-m-d H:i:s')]);
        }
    }