How to paginate a linked list?

69 views
Skip to first unread message

arikan

unread,
Apr 5, 2013, 4:01:16 AM4/5/13
to neo...@googlegroups.com
In the context of an activity stream, events are connected as a linked list via "next" edge, so we get things ordered by default. A query like this in a rails controller would return the last 20 events sorted:

events = last_event.incoming("next").depth(20)

What would be the strategy to paginate this query? 

Feeding back the id of last event as a parameter from rails view to the controller and finding it via Lucene and call this query would work but, there should be smarter way I feel. Or is there a way so that "will_paginate" gem can handle linked lists as well?

Thanks,
Burak

Andreas Ronge

unread,
Apr 5, 2013, 5:42:12 AM4/5/13
to neo...@googlegroups.com
Hi

Maybe not without some hacking.

The following classes in Neo4j supports pagination, see https://github.com/dnagir/neo4j-will_paginate/blob/master/lib/neo4j-will_paginate.rb

For example does Neo4j::Core::Traversal::Traverser support pagination.
So maybe you can try to get the last_event.incoming("next").depth(20) return a Neo4j::Core::Traversal::Traverser instead.
Or as an alternative you can try to let the object returned by last_event.incoming("next").depth(20) support will paginate by including the  Neo4j
::WillPaginate::Pagination mixin in the object retured by last_event.incoming("next").depth(20).

Pull Request are welcome :)


Cheers 






--
You received this message because you are subscribed to the Google Groups "neo4jrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4jrb+u...@googlegroups.com.
To post to this group, send email to neo...@googlegroups.com.
Visit this group at http://groups.google.com/group/neo4jrb?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages