GithubHelp home page GithubHelp logo

Comments (7)

norkunas avatar norkunas commented on June 9, 2024

Hey.
Could you open a PR with your fix? :)

from meilisearch-symfony.

bpolaszek avatar bpolaszek commented on June 9, 2024

Seems a little hacky, plus it requires end user the knowledge of having to flag each DateTimeInterface property with
#[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'U'])].

We could enforce that context configuration to avoid that, but this could conflict with other serializer usages, which prefer using DateTimeInterface::ATOM for serialization (typically, API-Platform projects).

Another solution would be to drop some arbitrary property in the context as early as possible, to tell the serializer that it's the bundle that requested the serialization. This way it would know that DateTimeInterface objects have to be normalized as unix timestamp integers.

Or, the ability to use a different serializer instance.

I'll try to have a look at this.

from meilisearch-symfony.

norkunas avatar norkunas commented on June 9, 2024

I think we can add format key to the context in Meilisearch\Bundle\SearchableEntity::getSearchableArray without breaking anything 🤔

from meilisearch-symfony.

bpolaszek avatar bpolaszek commented on June 9, 2024

I think we can add format key to the context in Meilisearch\Bundle\SearchableEntity::getSearchableArray without breaking anything 🤔

Oh, didn't think about that, I just dropped #309 with a meilisearch: true context parameter. Might be useful in some other cases tho - WDYT?

from meilisearch-symfony.

norkunas avatar norkunas commented on June 9, 2024

If meilisearch allows to store timestamps as strings then I'd go for directly configuring format without adding meilisearch to the context, but this needs to be tested then, otherwise current solution is the way to go 👍

from meilisearch-symfony.

bpolaszek avatar bpolaszek commented on June 9, 2024

Nope, I already tested that, dates aren't searchable with date1 TO date2 filter when they're stored as a unix-timestamp strings - they have to be casted as integers, which is why I had to add a dedicated normalizer (otherwise using existing DateTimeNormalizer would have done the trick indeed)

from meilisearch-symfony.

norkunas avatar norkunas commented on June 9, 2024

Sadly there is no way to configure DateTimeNormalizer to call getTimestamp instead of format('U') 😞

from meilisearch-symfony.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.