Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

Commit 08ac2ba

Browse files
committed
fixed order users on list
1 parent 549ce91 commit 08ac2ba

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/controllers/users_controller.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ def show
2121
end
2222

2323
# FIXME: Change this When use ACTIVE_MODEL_CLASS as UserNeo4j
24-
@friends = User.where(:neo4j_uuid.in => friends.pluck(:uuid))
24+
uuids = friends.map { |node| node.props[:uuid] || node.uuid }
25+
@friends = User.where(:neo4j_uuid.in => friends.pluck(:uuid)).
26+
to_a.sort_by { |value| uuids.index(value.neo4j_uuid) } # preserving order
27+
2528
@friends_path = friends_path&.transform_values do |item|
2629
uuids = item.map { |node| node.props[:uuid] || node.uuid }
2730

2831
# it is necessary to order after query in database to preser correct path
2932
User.where(:neo4j_uuid.in => uuids).
30-
to_a.sort_by { |value| uuids.index(value.neo4j_uuid) }
33+
to_a.sort_by { |value| uuids.index(value.neo4j_uuid) } # preserving order
3134
end
3235
end
3336

app/models/user_neo4j.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def friends_by_search(term)
7272

7373
total += (friends_path[item.uuid].length - 2) * 10
7474
total += item.titles.any? { titles.include?(term) } ? -10 : 0
75-
total += item.subtitles.any? { |subtitle| subtitle.include?(term) } ? -5 : 0
7675

7776
total
7877
end

0 commit comments

Comments
 (0)