-
Notifications
You must be signed in to change notification settings - Fork 91
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
Getter of has_many or has_one relationship gets called twice #99
Comments
That definitely could be a problem and one I'd love to get fixed. Let me know if you have some time to dig into it, would love some help identifying it. |
Ok, currently I have less time, but I forked it already and will dig into it if I have some. |
I have read through code. In my opinion the data providers should take care of how they provide data. Currently the data-providers are the domain-objects itself and they can't be changed. So I implemented a thin proxy-object-class(JSONAPI::ProxyObject i.e.) and such a proxy-object-instance delegates the getter-methods to the domain-objects and take care of memoizing return values for following calls. This works quite good at first sight. So I want to know what you think about my approach. If you are interested I could provide a PR. |
@fotinakis I see you released a v1.0.0 👍 with some huge perf-improvements. |
@wuarmin so that sounds ok, just two assumptions that it makes: 1) the proxy object will always return data correctly, ie. it's ok to memoize values, and 2) it assumes that asking objects for values is currently a performance problem. On the second point, here is a ruby-prof profiler recording of a big API serialization response: Someone else (@JonasBorchelt) forked this gem recently to add a "store" layer, which I'm not sure if it does exactly what you're talking about but I think it's also close: etventure@63a45a3 My big concern is backwards-compatibility, so as long as PR takes that into account I'm very interested in perf fixes. |
Hello,
following test code illustrates the behaviour:
Is this the expected behaviour? Maybe an if-statement? I did not look deep in code yet.
Our problem is, that we have some time-consuming "getter"-functions and don't want to use/aren't able to use members.
Best regards!
The text was updated successfully, but these errors were encountered: