Closed jayesbe closed 8 years ago
Hi,
Do you use docrtrine ORM ? If yes, do you see something in action
table after you update the action ?
Im using Redis.
I can see the actions records in redis under key spy_timeline:action
O:25:"Spy\Timeline\Model\Action":10:{s:5:" * id";i:41;s:7:" * verb";s:7:"control";s:16:" * statusCurrent";s:7:"pending";s:15:" * statusWanted";s:9:"published";s:15:" * duplicateKey";N;s:20:" * duplicatePriority";N;s:13:" * duplicated";b:0;s:12:" * createdAt";O:8:"DateTime":3:{s:4:"date";s:19:"2016-01-12 06:37:53";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"America/New_York";}s:19:" * actionComponents";a:2:{i:0;O:34:"Spy\Timeline\Model\ActionComponent":5:{s:5:" * id";N;s:7:" * type";s:16:"directComplement";s:7:" * text";s:9:"the world";s:9:" * action";r:1;s:12:" * component";N;}i:1;O:34:"Spy\Timeline\Model\ActionComponent":5:{s:5:" * id";N;s:7:" * type";s:7:"subject";s:7:" * text";N;s:9:" * action";r:1;s:12:" * component";O:28:"Spy\Timeline\Model\Component":4:{s:5:" * id";N;s:8:" * model";s:5:"\User";s:13:" * identifier";s:4:"3035";s:7:" * hash";s:17:"\User#s:4:"3035";";}}}s:12:" * timelines";a:0:{}}
Ohh ... it's been a loooong time I didn't test things on Redis.
You should look at https://github.com/stephpy/timeline/tree/master/src/Driver/Redis then debug to know why it don't return the action ...
Is doctrine / SQL a better option from a pure performance point of view?
You'll be able to do more things:
Redis is awesome for Key=>Value systems, I implemented timeline in redis but it's a bit tricky in my opinion. It could work with redis and work better than mysql ... but it's harder to maintain, and community will not really help you. So globally I would recommend you to use doctrine/orm.
Deploying asynchronously in my opinion is better handled by rabbit mq (amqplib) rather than using redis. This way at least it doesn't even need to be instant. I want to use redis for performance reasons. But you definitely do get the power of relations with Doctrine. I'll take your suggest under advisement though.. I could always cache the timeline in redis using Doctrine result cache.
Thanks for the help.
You're welcome.
Hey Stéphane. Hopefully a quick question.. Im lost as to how to make this timeline render correctly and store what im expecting it to using Doctrine.
$actionManager = $this->get('spy_timeline.action_manager');
$timelineManager = $this->get('spy_timeline.timeline_manager');
$subject = $actionManager->findOrCreateComponent('UserBundle\Entity\User', $this->getUser()->getId());
$action = $actionManager->create($subject, 'control', array('directComplement' => 'the world'));
$actionManager->updateAction($action);
$timeline = $timelineManager->getTimeline($subject);
after I do this I have this in my twig
{% for action in timeline %}
{{ timeline_render(action) }}
{% endfor %}
all I see in my browser is
when I dump the contents.. I see the subject (my user) is stored like this
#id: 4
#action: Action {#3752}
#component: Component {#3693 ▶}
#type: "subject"
#text: null
the text is null.. it says in the doc the text comes from __toString() of the model. So when I pass in the User entity into the 'findOrCreateComponent' .. it throws an exception .. expecting array or scaler..
Can you provide some insight here bro.. what I am doing wrong ?
Hi,
Do you use DataHydrator ?
ah ok. I was able to get it working. Its working nicely. Ill checkout hydrator to reduce number of queries.
thanks man.
You're welcome. :)
Im trying to create a timeline for events. There are no friends in this system. The user that logs in has their own personal event timeline. The user as he or she interacts with the system will trigger events that I want to show in their timeline.
For example, User registers. User logs in for first time. User completes a survey.
The timeline should be:
I created a very very simple action to test timeline integration
Everything returns empty. If I dump the $action right after updateAction, I see the action has an ID. and it keeps increasing as I refresh the page. But the timeline remains empty. Why?
I would appreciate any help here as this example is just brutally perplexing and utterly as simple as I can make it.