Database Reference
In-Depth Information
Figure 10-15. The consumption console
Listing 10-40. The consumption console Route and Methods to Get Connected Products and Users via Tags
# displays products that are connected to users via a tag relationship
get '/consumption/console' do
@title="Consumption Console"
if params[:tag] && !params[:tag].empty?
@usersWithMatchingTags = get_products_has_specific_tag_and_user_users_specific_
tag(neo,params[:tag])
else
@usersWithMatchingTags = get_products_has_a_tag_and_user_users_a_matching_tag(neo)
end
mustache :"graphs/consumption/console"
end
# products that share any tag with a user
def get_products_has_a_tag_and_user_users_a_matching_tag(neo)
cypher = " MATCH (p:Product)-[:HAS]->(t)<-[:USES]-(u:User) "+
" RETURN p.title as title , collect(u.username) as users, " +
" collect(distinct t.wordPhrase) as tags "
results=neo.execute_query(cypher)
results["data"].map {|row| Hash[results["columns"].zip(row)] }
end
 
Search WWH ::




Custom Search