Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

About the DataHydrator filter_unresolved = true no items display #168

Open
taylor19882002 opened this issue Nov 23, 2014 · 15 comments
Open

Comments

@taylor19882002
Copy link
Contributor

Hi Stephpy

I'm not sure that problem is my misunderstand or not

my problem

  1. create
    $actionManager = $this->get('spy_timeline.action_manager');
    $subject = $actionManager->findOrCreateComponent('a\model', 'chucknorris');
    $action = $actionManager->create($subject, 'control', array('directComplement' => 'the world'));
    $actionManager->updateAction($action);

  2. get timeline
    $actionManager = $this->get('spy_timeline.action_manager');
    $timelineManager = $this->get('spy_timeline.timeline_manager');
    $subject = $actionManager->findOrCreateComponent('a\model', 'chucknorris');
    $timeline = $timelineManager->getTimeline($subject);

if filter_unresolved = false, get the related items
{"coll":{"items":[..........],"last_page":1,"page":1,"nb_results":1}}

if filter_unresolved = true, get nothing, i don't know why it filter out self action.
{"coll":{"items":[],"last_page":1,"page":1,"nb_results":1}}

regards
Oscar

@taylor19882002 taylor19882002 changed the title About the DataHydrator filter_unresolved = true not item display About the DataHydrator filter_unresolved = true no items display Nov 24, 2014
@stephpy
Copy link
Owner

stephpy commented Nov 24, 2014

Hi, it's because filter_unresolved will remove from collection actions with unresolved components.

Here, if a\model (primary key: chuckNorris) cannot be resolved (does not exist if you didn't write a new resolver), it'll remove the action from collection.

@taylor19882002
Copy link
Contributor Author

Thank you for your reply. But I use ODM driver, after I trace previous related issues, Need to set the Identifier ? sorry I'm just a novice of symfony, not well understand.

@stephpy
Copy link
Owner

stephpy commented Nov 24, 2014

I'm not sure to understand what do you say.

Yes, you have to persist your entities (in ORM or ODM) before pushing them into timeline as component.

@taylor19882002
Copy link
Contributor Author

Hi Stephpy, I still in a error. T.T

Now, I create a User class as the component, when filter_unresolved = true, it can show someone timeline with no spread, but when I add-on the spread service, if the timeline include another user action get below error. if no enable data_hydrator can be ok. I have not idea, how to solve it. I 'm trying to understand the DataHydrator logic.

ContextErrorException: Notice: Array to string conversion in
/............/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Query/Builder.php line 333
at ErrorHandler->handle('8', 'Array to string conversion', '/............/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Query/Builder.php', '333', array('field' => array('id'), 'this' => object(Builder))) in /............/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Query/Builder.php line 333
at Builder->field(array('id')) in /............/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Query/Builder.php line 121
at Builder->field(array('id')) in /.........../vendor/stephpy/timeline-bundle/Filter/DataHydrator/Locator/DoctrineODM.php line 64
at DoctrineODM->locate('Acme\StoreBundle\Document\User', array('Acme\StoreBundle\Document\User#s:24:"547429bad03b7c4704b7ad5e";' => object(Component))) in /.........../vendor/stephpy/timeline/src/Filter/DataHydrator.php line 101
at DataHydrator->hydrateComponents(object(Pager)) in /.........../vendor/stephpy/timeline/src/Filter/DataHydrator.php line 68

@stephpy
Copy link
Owner

stephpy commented Nov 25, 2014

You entity has a composite key ? It seems error come from:

https://github.com/stephpy/timeline-bundle/blob/master/Filter/DataHydrator/Locator/DoctrineODM.php#L62 which give $field as an array, it should not.

@taylor19882002
Copy link
Contributor Author

No entity as
array (
'_id' => '547429bad03b7c4704b7ad5e',
'username' => 'morris',
)

@stephpy
Copy link
Owner

stephpy commented Nov 25, 2014

@taylor19882002
Copy link
Contributor Author

Array ( [0] => id )

@stephpy
Copy link
Owner

stephpy commented Nov 25, 2014

Try to add $field = current($field); before line 62.

@taylor19882002
Copy link
Contributor Author

That error has removed, Thank you so much!

@stephpy
Copy link
Owner

stephpy commented Nov 25, 2014

I'll make a patch as soon as possible.

@taylor19882002
Copy link
Contributor Author

hm.... I find something out of my expectation.
let me re-explain the old question
DataHydrator filter_unresolved = true can be filter out the action push from some guys and already removed from their timeline, that action will not show up in my timeline, Am i right ?

@stephpy
Copy link
Owner

stephpy commented Nov 25, 2014

It is explained in documentation, cannot be more explicit.

@taylor19882002
Copy link
Contributor Author

DataHydrator filter_unresolved = true not work in ODM, that's why I ask above question. By the way, I really thank you for your reply.

I remove a directComplement which referring in a timeline, when I pull the timeline get the error show as:

The "MongoDBODMProxies__CG__\Acme\StoreBundle\Document\Component" document with identifier "547450f6d03b7c4304b7ad7d" could not be found.
at DocumentNotFoundException ::documentNotFound ('MongoDBODMProxies__CG__\Acme\StoreBundle\Document\Component', '547450f6d03b7c4304b7ad7d')
in/...../vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php at line 176 +
at ProxyFactory ->Doctrine\ODM\MongoDB\Proxy{closure} (object(Component), 'getData', array())
in kernel.root_dir/cache/dev/doctrine/odm/mongodb/Proxies/__CG__AcmeStoreBundleDocumentComponent.php at line 243 +
at Closure ->__invoke (object(Component), 'getData', array())
in kernel.root_dir/cache/dev/doctrine/odm/mongodb/Proxies/__CG__AcmeStoreBundleDocumentComponent.php at line 243 +
at Component ->getData ()
in /..../vendor/stephpy/timeline/src/Filter/DataHydrator/Entry.php at line 59 +
at Entry ->buildComponent (object(ActionComponent))
in /....../vendor/stephpy/timeline/src/Filter/DataHydrator/Entry.php at line 44 +
at Entry ->build ()
in /...../vendor/stephpy/timeline/src/Filter/DataHydrator.php at line 63 +
at DataHydrator ->filter (object(Pager))
in /...../vendor/stephpy/timeline/src/Filter/FilterManager.php at line 40

@stephpy
Copy link
Owner

stephpy commented Dec 4, 2014

I don't use ODM, did you find something which could fix this usecase ?

taylor19882002 added a commit to taylor19882002/timeline-bundle that referenced this issue Jan 17, 2015
fix enable DataHydrator bug
stephpy#168
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants