Skip to content
Snippets Groups Projects
Commit 73031b0a authored by Bruno Nocera Zanette's avatar Bruno Nocera Zanette
Browse files

Add Like count to LearningObject's show page

parent b9c841f9
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,9 @@ class LearningObjectsController < ApplicationController
def show
@object = repository.for(:object).get_by_dspaceid params[:id]
unless @object.nil?
@like_counts = repository.for(:edge).get_in_edges_count "ELike", @object.first["@rid"]
end
end
def new
......
module OrientDb
class EdgeRepository < Base
def get_in_edges_count(edge_class, id)
OrientDb::Client.instance.query "SELECT COUNT(@rid) FROM #{edge_class} WHERE in = #{id}"
end
def create_like_edge(from_id, to_id)
OrientDb::Client.instance.command "CREATE EDGE ELike FROM #{from_id} TO #{to_id}"
end
......
......@@ -17,4 +17,5 @@
{ action: "create", controller: "graph_tests" },
method: :post,
params: { from_id: " #14:0", to_id: get_object_property(@object,"@rid") }
) %>
)%>
Total Curtir: <%= get_object_property(@like_counts,"COUNT") %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment