Skip to content
Snippets Groups Projects
Commit d3909d50 authored by Matheus Agio Nerone's avatar Matheus Agio Nerone
Browse files

fix typo at edge_methods, fix merge modifications

parent 5f7d681c
No related branches found
No related tags found
No related merge requests found
......@@ -10,19 +10,18 @@ class WelcomeController < ApplicationController
end
@General = mainPage[0]["highlights"].collect do |id|
repository.for(:learning_object).find_by_id(id)[0]
repository.for(:learning_object).find(id)
end
@Subjects = repository.for(:subject).find_all.take(8)
@Subjects.delete_if do |subject|
if subject['highlights'].nil? || subject['highlights'].empty?
true
end
end
@Subjects.each do |subject|
puts subject['highlights'].first
puts '@@@@'
object = repository.for(:learning_object).find_by_id(subject['highlights'].first)
puts object
puts '@@@@'
subject['first_highlight'] = object[0]
puts subject
puts '------------------'
object = repository.for(:learning_object).find(subject['highlights'].first)
subject['first_highlight'] = object
end
end
......
......@@ -37,7 +37,7 @@ module OrientDb
# learning_object = repository.for(:learning_objects).get_by_dspace_id 123
#
def find(id)
result = connection.query "SELECT FROM '#{id}'"
result = connection.query "SELECT FROM #{id}"
build_learning_object result.first
end
......@@ -65,29 +65,6 @@ module OrientDb
# likes[0]["outE"]
#end
def has(rid)
connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM User WHERE @rid=#{rid})"
end
def find_all
connection.query("SELECT FROM LearningObject",{:limit=>-1} )
end
def find_by_id(id)
connection.query "SELECT FROM LearningObject where @rid = '#{id}'"
end
def insert_data (name, url)
connection.command "INSERT INTO LearningObject (name,URL) VALUES ('#{name}','#{url}')"
end
def destroy_data(id)
return @connection.command "DELETE VERTEX LearningObject where @rid = '#{id}'"
rescue
return nil
end
private
def count_likes(learning_object)
......@@ -113,7 +90,6 @@ module OrientDb
hash.each do |h|
learning_objects << build_learning_object(h)
end
learning_objects
end
......
......@@ -59,11 +59,15 @@
</a>
</div>
<div class="media-body">
<h4 class="media-heading"><%= highlight['name'] %></h4>
<% if highlight.title.nil? %>
<h4 class="media-heading">Sem Título</h4>
<% else %>
<h4 class="media-heading"><%= highlight.title %></h4>
<% end %>
<span>Por <a>Usuário&nbsp</a></span>
<span class="glyphicon glyphicon-eye-open"><%= highlight['views'] %>&nbsp </span>
<span class="glyphicon glyphicon-star"><%= highlight['likes'] %>&nbsp</span><br>
<%= highlight['description']%><br>
<span class="glyphicon glyphicon-eye-open"><%= highlight.views.count %>&nbsp </span>
<span class="glyphicon glyphicon-star"><%= highlight.likes.count %>&nbsp</span><br>
<%= highlight.description%><br>
Em<b> Biologia</b>, <b>Biologia Marinha</b>
</div>
</div>
......@@ -80,17 +84,22 @@
<div class="row">
<div class="col-md-11 col-sm-offset-1 padding-left-0">
<% unless @Subjects.nil? || @Subjects.empty?%>
<h2>Em Destaque</h2>
<ul class="list-unstyled">
<% @Subjects.each do |subject|%>
<li class="col-sm-3 padding-left-0">
<div class="media">
<h4><b><%= subject['name']%></b></h4>
<h4><b><%= subject['name'].truncate(20)%></b></h4>
<div>
<img src="http://dummyimage.com/250x150/363336/fff" alt='dummy image' class="img-responsive">
</div>
<div class="media-body">
<h4 class="media-heading"><%= subject['first_highlight']['name'] %></h4>
<% if subject['first_highlight'].title.nil? %>
<h4 class="media-heading">Sem Título</h4>
<% else %>
<h4 class="media-heading"><%= subject['first_highlight'].title %></h4>
<% end %>
<span>Por <a>Usuário&nbsp</a></span>
<span class="glyphicon glyphicon-eye-open">200&nbsp </span>
<span class="glyphicon glyphicon-star">4,5&nbsp</span>
......@@ -102,6 +111,7 @@
</li>
<% end %>
</ul>
<% end %>
</div>
</div>
</div>
......@@ -3,7 +3,7 @@ module OrientDb
module EdgeMethods
def get_in_edges_count(edge_class, id)
connection.query sprintf("SELECT COUNT(@rid) FROM %s WHERE in = %d", edge_class, id)
connection.query sprintf("SELECT COUNT(@rid) FROM %s WHERE in = %s", edge_class, id)
end
def create_edge(edge_class, from_id, to_id)
......@@ -12,4 +12,4 @@ module OrientDb
end
end
end
\ No newline at end of file
end
......@@ -3,12 +3,10 @@ namespace :mainPage do
task :highlights => :environment do
repository = Portalmec::Application.repository
puts 'Generating the main page highlights'
objects = repository.for(:learning_object).find_all
objects = repository.for(:learning_object).all
objects = objects.collect do |object|
likes = repository.for(:learning_object).get_likes(object['@rid']).size()
views = repository.for(:learning_object).get_views(object['@rid']).size()
downloads = repository.for(:learning_object).get_downloads(object['@rid']).size()
Ranking::Item.new(object['@rid'],views,downloads,likes)
downloads = 0
Ranking::Item.new(object.id,object.views.count,downloads,object.likes.count)
end
rater = Ranking::Rater.new(Ranking::Strategies::BasicRater.new(1000,1,100))
objects = rater.sortByRate(objects).take(5)
......@@ -22,24 +20,19 @@ namespace :mainPage do
puts 'Generate the main page subject highlights'
subjects = repository.for(:subject).find_all
puts 'Found the subjects'
subjects.each do |subject|
puts subject
#pego os objetos sobre aquele subject
objects = repository.for(:subject).get_objects(subject['@rid'])
puts objects
puts '-----------------------------------------------'
#para todos os objetos eu transformo eles em items para rankear
objects = objects.collect do |object|
likes = repository.for(:learning_object).get_likes(object['@rid']).size()
views = repository.for(:learning_object).get_views(object['@rid']).size()
downloads = repository.for(:learning_object).get_downloads(object['@rid']).size()
Ranking::Item.new(object['@rid'],views,downloads,likes)
downloads = 0
object = repository.for(:learning_object).find(object['@rid'])
Ranking::Item.new(object.id,object.views.count,downloads,object.likes.count)
end
#rankeio eles
rater = Ranking::Rater.new(Ranking::Strategies::BasicRater.new(1000,1,100))
objects = rater.sortByRate(objects)
#adciono no highlights do subject
puts subject['name']
repository.for(:subject).update(subject['@rid'],'set','highlights','[]')
objects.each do |object|
repository.for(:subject).update(subject['@rid'],'add','highlights',object.name)
......
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