This repository was archived by the owner on Nov 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010Run the below code:
1111
1212```
13- docker-compose run web
13+ docker-compose up web
1414```
1515
1616## Setup
Original file line number Diff line number Diff line change @@ -54,8 +54,10 @@ def friends_by_search(term)
5454 where ( 'ANY(title IN l.titles WHERE toLower(title) CONTAINS toLower({title})) OR
5555 ANY(subtitle IN l.subtitles WHERE toLower(subtitle) CONTAINS toLower({title}))' ) .
5656 where ( 'l <> user' ) .
57- params ( { title : term } )
57+ params ( { title : term } ) .
58+ to_a
5859
60+ # TODO: Use only one query to get users and shortest paths
5961 friends . each do |friend |
6062 friends_path [ friend . uuid ] = Neo4j ::ActiveBase . current_session .
6163 query ( "MATCH (r:UserNeo4j { uuid: '#{ uuid } ' }),
@@ -64,6 +66,17 @@ def friends_by_search(term)
6466 RETURN p" , limit : 1 ) . first . p . nodes
6567 end
6668
69+ # TODO: Use only queries to generate order
70+ friends . sort_by! do |item |
71+ total = 0
72+
73+ total += ( friends_path [ item . uuid ] . length - 2 ) * 10
74+ total += item . titles . any? { titles . include? ( term ) } ? -10 : 0
75+ total += item . subtitles . any? { |subtitle | subtitle . include? ( term ) } ? -5 : 0
76+
77+ total
78+ end
79+
6780 [ friends , friends_path ]
6881 end
6982
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def self.titles(url)
1313
1414 {
1515 titles : nokogiri . search ( 'h1' ) . map { |item | item . text . squish } ,
16- subtitles : nokogiri . search ( 'h2' ) . map { |item | item . text . squish } ,
16+ subtitles : nokogiri . search ( 'h2, h3 ' ) . map { |item | item . text . squish } ,
1717 }
1818 end
1919end
You can’t perform that action at this time.
0 commit comments