Database Reference
In-Depth Information
Filtering Connected Content
If a tag is clicked on the inside of the “Interests in my Network” section, then get_following_content_with_tag
method will be called, as shown in Listing 10-37. The second query is nearly identical the first query found in the
interest route, except that it will factor in the users being followed and exclude the current user. The method also
returns a collection of status updates based on the matching tag, placing no limit on the number of status updates to
be returned. In addition, it marks the owner property as true, because you've determined ahead of time you are only
returning the current user's content. The results of calling this method are shown in Figure 10-13 .
Listing 10-37. Get the Content of the User's Being Followed Based on a Tag
def get_following_content_with_tag(neo,username,wordPhrase)
cypher = " MATCH (u:User {username: {u} })-[:FOLLOWS]->f" +
" WITH DISTINCT f" +
" MATCH f-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-p" +
" WITH DISTINCT f,p" +
" MATCH p-[:HAS]-(t:Tag {wordPhrase : {wp} } )" +
" RETURN p.contentId as contentId, p.title as title, p.tagstr as tagstr, " +
" p.timestamp as timestamp, p.url as url, f.username as username, false as owner" +
" ORDER BY p.timestamp DESC"
results=neo.execute_query(cypher, {:u => username, :wp => wordPhrase} )
r=results["data"].map {|row| Hash[*results["columns"].zip(row).flatten] }
r.each do |e|
Figure 10-13. Filtering content of the current user's friends
 
Search WWH ::




Custom Search