Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time search on date not working #784

Open
Rasoul-Karimi opened this issue Jan 26, 2023 · 5 comments
Open

time search on date not working #784

Rasoul-Karimi opened this issue Jan 26, 2023 · 5 comments

Comments

@Rasoul-Karimi
Copy link

Rasoul-Karimi commented Jan 26, 2023

hi
i want to get all item From '2023-01-31 07:00:00' until '2023-01-31 07:30:00' for example:

i search looks like: search=start_at:'2023-01-31 07:00:00', '2023-01-31 07:30:00'&searchFields=start_at:between and in config file add between condition but not working! search on hour and minute not work! return all days!

@Rasoul-Karimi
Copy link
Author

??

@jeffersonsalvador
Copy link

I had a similar problem, when I search for some time for example: 14:00.
Apparently it's breaking all information containing ":" into field:value

?search=schedule.expression:'14:00'

Screenshot 2023-02-02 at 08 55 23

?search="14:00"

Screenshot 2023-02-02 at 08 57 55

@Rasoul-Karimi
Copy link
Author

up

@Rasoul-Karimi
Copy link
Author

any answer and solution?

@mCassy
Copy link

mCassy commented Dec 30, 2024

I do not think there is a quick/simple solution to this since attr/value separators are hardcoded in the RequestCriteria class.

Personally, I would go with some custom criteria class that I would push whenever it's needed. For example, having
?start_at='2024-01-01 12:14:25,2025-01-01 12:14:25' query param you can create a custom criteria class that accepts your start_at value

class StartAtBetweenCriteria implements CriteriaInterface
{
    public function __construct(private string $startAtBetween)
    {
    }

    public function apply($model, RepositoryInterface $repository)
    {
        $startAtBetween = explode(',', $this->startAtBetween);
        if (isset($startAtBetween[0]) && isset($startAtBetween[1])) {
            $model = $model->whereBetween("start_at", "=", $startAtBetween);
        }
        return $model;
    }
}

Later on, you can push this criteria whenever you need it, ie

$this->repository->pushCriteria(new StartAtBetweenCriteria($request->get('start_at')));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants