diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 99f7e706f38a24719b0fa5b6b60f5189f74c0d69..0000000000000000000000000000000000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,384 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - abstract_type (0.0.7) - actionmailer (4.2.0) - actionpack (= 4.2.0) - actionview (= 4.2.0) - activejob (= 4.2.0) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.0) - actionview (= 4.2.0) - activesupport (= 4.2.0) - rack (~> 1.6.0) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - actionview (4.2.0) - activesupport (= 4.2.0) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - activejob (4.2.0) - activesupport (= 4.2.0) - globalid (>= 0.3.0) - activemodel (4.2.0) - activesupport (= 4.2.0) - builder (~> 3.1) - activerecord (4.2.0) - activemodel (= 4.2.0) - activesupport (= 4.2.0) - arel (~> 6.0) - activesupport (4.2.0) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - adamantium (0.2.0) - ice_nine (~> 0.11.0) - memoizable (~> 0.4.0) - arel (6.0.3) - ast (2.1.0) - autoprefixer-rails (6.1.0.1) - execjs - json - axiom-types (0.1.1) - descendants_tracker (~> 0.0.4) - ice_nine (~> 0.11.0) - thread_safe (~> 0.3, >= 0.3.1) - bcrypt (3.1.10) - better_errors (2.1.1) - coderay (>= 1.0.0) - erubis (>= 2.6.6) - rack (>= 0.9.0) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.5.1) - autoprefixer-rails (>= 5.0.0.1) - sass (>= 3.3.0) - builder (3.2.2) - bullet (4.14.10) - activesupport (>= 3.0.0) - uniform_notifier (~> 1.9.0) - byebug (8.2.0) - chart-js-rails (0.0.9) - railties (> 3.1) - chronic (0.10.2) - climate_control (0.0.3) - activesupport (>= 3.0) - cocaine (0.5.7) - climate_control (>= 0.0.3, < 1.0) - coderay (1.1.0) - coercible (1.0.0) - descendants_tracker (~> 0.0.1) - coffee-rails (4.1.0) - coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.10.0) - concord (0.1.5) - adamantium (~> 0.2.0) - equalizer (~> 0.0.9) - concurrent-ruby (1.0.0) - connection_pool (2.2.0) - curb (0.8.8) - dalli (2.7.4) - debug_inspector (0.0.2) - descendants_tracker (0.0.4) - thread_safe (~> 0.3, >= 0.3.1) - devise (3.5.2) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) - responders - thread_safe (~> 0.1) - warden (~> 1.2.3) - devise_token_auth (0.1.36) - devise (~> 3.5.2) - rails (~> 4.2) - diff-lcs (1.2.5) - domain_name (0.5.25) - unf (>= 0.0.5, < 1.0.0) - dspace_rest_client (1.1.2) - curb (~> 0.8.6) - rest-client (>= 1.7, < 2) - equalizer (0.0.11) - erubis (2.7.0) - execjs (2.6.0) - fast_stack (0.1.0) - rake - rake-compiler - flamegraph (0.1.0) - fast_stack - flay (2.6.1) - ruby_parser (~> 3.0) - sexp_processor (~> 4.0) - flog (4.3.2) - ruby_parser (~> 3.1, > 3.1.0) - sexp_processor (~> 4.4) - globalid (0.3.6) - activesupport (>= 4.1.0) - http-cookie (1.0.2) - domain_name (~> 0.5) - i18n (0.7.0) - ice_nine (0.11.1) - jbuilder (2.3.2) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - jquery-rails (4.0.5) - rails-dom-testing (~> 1.0) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - jquery-turbolinks (2.1.0) - railties (>= 3.1.0) - turbolinks - jquery-ui-rails (5.0.5) - railties (>= 3.2.16) - json (1.8.3) - kaminari (0.16.3) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - libarchive-static (1.0.5) - libv8 (3.16.14.13) - locastyle (0.0.2) - loofah (2.0.3) - nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - memoizable (0.4.2) - thread_safe (~> 0.3, >= 0.3.1) - mime-types (2.6.2) - mimemagic (0.3.0) - mina (0.3.7) - open4 (~> 1.3.4) - rake - mini_portile (0.6.2) - minitest (5.8.2) - multi_json (1.11.2) - netrc (0.11.0) - nokogiri (1.6.6.3) - mini_portile (~> 0.6.0) - open4 (1.3.4) - orientdb4r (0.5.1) - rest-client (~> 1.7) - orm_adapter (0.5.0) - paperclip (4.3.1) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - cocaine (~> 0.5.5) - mime-types - mimemagic (= 0.3.0) - parser (2.2.3.0) - ast (>= 1.1, < 3.0) - pg (0.18.4) - private_attr (1.1.0) - procto (0.0.2) - puma (2.15.3) - rack (1.6.4) - rack-cors (0.4.0) - rack-mini-profiler (0.9.7) - rack (>= 1.1.3) - rack-protection (1.5.3) - rack - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.0) - actionmailer (= 4.2.0) - actionpack (= 4.2.0) - actionview (= 4.2.0) - activejob (= 4.2.0) - activemodel (= 4.2.0) - activerecord (= 4.2.0) - activesupport (= 4.2.0) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.0) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) - loofah (~> 2.0) - railties (4.2.0) - actionpack (= 4.2.0) - activesupport (= 4.2.0) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (2.0.0) - rake (10.4.2) - rake-compiler (0.9.5) - rake - rdoc (4.2.0) - redis (3.2.2) - reek (3.6.0) - parser (~> 2.2, >= 2.2.2.5) - private_attr (~> 1.1) - rainbow (~> 2.0) - unparser (~> 0.2.2) - ref (2.0.0) - responders (2.1.0) - railties (>= 4.2.0, < 5) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rmagick (2.15.4) - rsolr (1.0.13) - builder (>= 2.1.2) - ruby_parser (3.7.2) - sexp_processor (~> 4.1) - rubycritic (2.1.0) - flay (= 2.6.1) - flog (= 4.3.2) - parser (>= 2.2.0, < 3.0) - reek (= 3.6.0) - virtus (~> 1.0) - sass (3.4.19) - sass-rails (5.0.4) - railties (>= 4.0.0, < 5.0) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - sdoc (0.4.1) - json (~> 1.7, >= 1.7.7) - rdoc (~> 4.0) - select2-rails (4.0.0) - thor (~> 0.14) - sexp_processor (4.6.0) - shoulda (3.5.0) - shoulda-context (~> 1.0, >= 1.0.1) - shoulda-matchers (>= 1.4.1, < 3.0) - shoulda-callback-matchers (1.1.3) - activesupport (>= 3) - shoulda-context (1.2.1) - shoulda-matchers (2.8.0) - activesupport (>= 3.0.0) - sidekiq (4.0.0) - concurrent-ruby (~> 1.0) - connection_pool (~> 2.2, >= 2.2.0) - json (~> 1.0) - redis (~> 3.2, >= 3.2.1) - sinatra (1.4.6) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) - slim (3.0.6) - temple (~> 0.7.3) - tilt (>= 1.3.3, < 2.1) - spring (1.4.3) - sprockets (3.4.0) - rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - sqlite3 (1.3.11) - stackprof (0.2.7) - streamio-ffmpeg (1.0.0) - temple (0.7.6) - therubyracer (0.12.2) - libv8 (~> 3.16.14.0) - ref - thor (0.19.1) - thread_safe (0.3.5) - tilt (2.0.1) - turbolinks (2.5.3) - coffee-rails - tzinfo (1.2.2) - thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.1) - uniform_notifier (1.9.0) - unparser (0.2.4) - abstract_type (~> 0.0.7) - adamantium (~> 0.2.0) - concord (~> 0.1.5) - diff-lcs (~> 1.2.5) - equalizer (~> 0.0.9) - parser (~> 2.2.2) - procto (~> 0.0.2) - virtus (1.0.5) - axiom-types (~> 0.1) - coercible (~> 1.0) - descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) - warden (1.2.3) - rack (>= 1.0) - web-console (2.2.1) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) - whenever (0.9.4) - chronic (>= 0.6.3) - -PLATFORMS - ruby - -DEPENDENCIES - bcrypt (~> 3.1.7) - better_errors - bootstrap-sass - bullet - byebug - chart-js-rails - coffee-rails (~> 4.1.0) - curb (~> 0.8.8) - dalli - devise - devise_token_auth - dspace_rest_client (~> 1.1.0) - execjs - flamegraph - jbuilder (~> 2.0) - jquery-rails - jquery-turbolinks - jquery-ui-rails - kaminari - libarchive-static - locastyle - mina - orientdb4r - paperclip - pg - puma - rack-cors - rack-mini-profiler - rails (= 4.2.0) - rainbow - rdoc - rmagick - rsolr (~> 1.0.12) - rubycritic - sass-rails (~> 5.0) - sdoc (~> 0.4.0) - select2-rails - shoulda - shoulda-callback-matchers (~> 1.1.1) - sidekiq - sinatra - slim - spring - sqlite3 - stackprof - streamio-ffmpeg (~> 1.0.0) - therubyracer - turbolinks - uglifier (>= 1.3.0) - web-console (~> 2.0) - whenever - -BUNDLED WITH - 1.10.6 diff --git a/app/assets/javascripts/management.js b/app/assets/javascripts/management.js index 39015ad52fc026bbd220e467f3322a3c805bd118..18dfb4b228f40b77cbd57316bdbd77150eb614cf 100644 --- a/app/assets/javascripts/management.js +++ b/app/assets/javascripts/management.js @@ -19,14 +19,22 @@ //= require locastyle //= require turbolinks //= require_tree ./management - +var teachers, curators, admins; var visualised,non_visualised; $(document).ready(function(){ if (document.getElementById("lobject") !== null) { visualised = document.getElementById("lobject").value; non_visualised = document.getElementById("lobject_non").value; - var data_learning_objects = dataLearningObjects(visualised,non_visualised); + } + if (document.getElementById("n_teachers") !== null) { + + teachers = document.getElementById("n_teachers").value; + curators = document.getElementById("n_curators").value; + admins = document.getElementById("n_admins").value; + var data_users = dataUsers(teachers,curators,admins); + } + var charts = ["colections","users","learning_objects","accesses"]; @@ -44,7 +52,7 @@ $(document).ready(function(){ break; case "learning_objects": new Chart(ctx).Pie(data_learning_objects,pie_options); - var learning_objects_chart = new Chart(ctx).Pie(data_learnin_objects); + var learning_objects_chart = new Chart(ctx).Pie(data_learning_objects); break; case "accesses": new Chart(ctx).Line(data_accesses,line_options); @@ -57,7 +65,7 @@ $(document).ready(function(){ } } } -}); +); Chart.defaults.global = { // Boolean - Whether to animate the chart diff --git a/app/assets/javascripts/management/users.js b/app/assets/javascripts/management/users.js index 00e4ca158d99487f25169d175c177b7a8ef9d739..b1de9842736a54e3402762e8acc8df156c71f81e 100644 --- a/app/assets/javascripts/management/users.js +++ b/app/assets/javascripts/management/users.js @@ -1,19 +1,26 @@ //Configurações de gráficos BAR //mais infos www.chartjs.org/docs/ -var data_users = { - labels: ["Estudantes", "Professores", "Moderadores", "Admnistradores"], + +function dataUsers(teachers, curators, admins){ +var data = { + labels: [ "Professores", "Curadores", "Admnistradores"], datasets: [ { label: "My First dataset", - fillColor: "rgba(220,220,220,0.5)", - strokeColor: "rgba(220,220,220,0.8)", - highlightFill: "rgba(220,220,220,0.75)", - highlightStroke: "rgba(220,220,220,1)", - data: [20,42,7,1] + fillColor: "rgba(100,89,54,0.5)", + strokeColor: "rgba(1,34,65,0.8)", + highlightFill: "rgba(53,13,54,0.75)", + highlightStroke: "rgba(32,80,90,1)", + data: [teachers, curators, admins] }, ] }; +return data; + +} + + var bar_options = { diff --git a/app/builders/attribute_builder.rb b/app/builders/attribute_builder.rb index 6cfa32b7e733a8e153e4d9cf1ad05ebc8dffb9e4..379453c23e9a354fa9373dfbe11b3a247c3a81df 100644 --- a/app/builders/attribute_builder.rb +++ b/app/builders/attribute_builder.rb @@ -5,33 +5,17 @@ class AttributeBuilder < Builder # receive a list of ids and return a list of attributes # def self.build(attributes = []) - array = [] - attributes = [attributes] if attributes.class == String - attributes.each do |attributes| - unless attribute['@rid'].blank? - o = Rails.cache.fetch(cache_key(attribute['@rid'], attribute['last_modified'])) unless attribute['last_modified'].blank? - o = attribute_repository.find attribute['@rid'] if o.nil? - array << o - end - end - array + super(attribute_repository, attributes) end def self.build_from_orientdb(args = {}) - attribute = nil - - unless args.nil? - # cache object when build - attribute = Rails.cache.fetch(cache_key(args['@rid'], args['last_modified']), expires_in: 12.hours) do - Attribute.new( - id: args['@rid'], - key: args['key'], - value: args['value'] - ) - end + super(args) do + Attribute.new( + id: args['@rid'], + key: args['key'], + value: args['value'] + ) end - - attribute end end diff --git a/app/builders/builder.rb b/app/builders/builder.rb index 2235e8b8dfc591a1f91f9eff0c9831c67b57fb50..875c4956f6d0fae04b2e985857ac0bc946f1b204 100644 --- a/app/builders/builder.rb +++ b/app/builders/builder.rb @@ -2,6 +2,37 @@ class Builder protected + def self.build(repository, objects = [], cache = true, id = '@rid', last_modified = 'last_modified') + array = [] + objects = [objects] if objects.class == String || objects.class == Hash + objects.each do |object| + next if object[id].blank? + + if cache + o = Rails.cache.fetch(cache_key(object[id], object[last_modified])) unless object[last_modified].blank? + end + + o = repository.find object[id] if o.nil? + array << o + end + array + end + + def self.build_from_orientdb(args = {}, cache = true) + object = nil + + unless args.nil? || !block_given? + # cache object when build + if cache + object = Rails.cache.fetch(cache_key(args['@rid'], args['last_modified']), expires_in: 12.hours) { yield } + else + object = yield + end + end + + object + end + def self.cache_key(rid, last_modified) last_modified = Time.at(0).to_s if last_modified.nil? diff --git a/app/builders/collection_builder.rb b/app/builders/collection_builder.rb index 1ee607febdaa5145297e01d26c11c70431d3b28b..7c1b3d0c48e5addfea90efef1d5cc1cd7877482f 100644 --- a/app/builders/collection_builder.rb +++ b/app/builders/collection_builder.rb @@ -9,19 +9,12 @@ class CollectionBuilder < Builder # collection = CollectionBuilder.build [{'rid' => '#14:15', 'last_modified' => '2015-02-10 15:30'}] # # If the last_modified param is null, the object will be always reconstructed and updated in the cache - def self.build(objects = []) - lo = [] - objects.each do |object| - unless object['rid'].blank? - o = Rails.cache.fetch(cache_key(object['rid'], object['last_modified'])) - o = collection_repository.find object['rid'] if o.nil? - lo << o - end - end - lo + def self.build(collections = []) + super(subject_repository, collections, true, 'rid') end def self.build_from_orientdb(args = {}) +<<<<<<< HEAD lo = nil unless args.nil? # cache object when build @@ -39,8 +32,21 @@ class CollectionBuilder < Builder obj.last_modified = DateTime.strptime(args['last_modified'], "%Y-%m-%d %H:%M:%S") unless args['last_modified'].nil? obj end +======= + super(args) do + type = (args['name'] == 'Bookmarks') ? Bookmarks : Collection + obj = type.new( + learning_objects: LearningObjectBuilder.build(map_rid_to_object(args['learning_objects']) || []), + privacy: args['privacy'], + id: args['@rid'] + ) + obj.name = args['name'] unless type == Bookmarks + obj.owner = collection_repository.owner(args['@rid']) + obj.created_at = DateTime.strptime(args['created_at'], "%Y-%m-%d %H:%M:%S") unless args['created_at'].nil? + obj.last_modified = DateTime.strptime(args['last_modified'], "%Y-%m-%d %H:%M:%S") unless args['last_modified'].nil? + obj +>>>>>>> master end - lo end def self.map_rid_to_object(ids) diff --git a/app/builders/complaint_builder.rb b/app/builders/complaint_builder.rb index 2b977bc8bf1e55f4e74ca4f2a6b7a55d3e8545c2..c04de38c78aa91457e6166ff43be681a93d9b2b4 100644 --- a/app/builders/complaint_builder.rb +++ b/app/builders/complaint_builder.rb @@ -5,30 +5,21 @@ class ComplaintBuilder < Builder # receive a list of ids and return a list of complaints # def self.build(complaints = []) - array = [] - complaints = [complaints] if complaints.class == String - complaints.each do |complaint| - rid = complaint['@rid'] || complaint['rid'] - unless rid.blank? - o = complaint_repository.find complaint['@rid'] #if o.nil? - array << o - end - end - array + super(complaint_repository, complaints) end def self.build_from_orientdb(args = {}) - unless args.nil? + super(args, false) do created = DateTime.now.strftime("%Y-%m-%d %H:%M:%S") created = DateTime.strptime(args['created_at'], "%Y-%m-%d %H:%M:%S") unless args['created_at'].blank? Complaint.new( - id: args['@rid'], - user: user_repository.get_by_rid(args['out']), - created_at: created, - object: learning_object_repository.find(args['in'].to_s), - message: ComplaintMessage.new(args['message']), - description: args['description'] || '' + id: args['@rid'], + user: user_repository.get_by_rid(args['out']), + created_at: created, + object: learning_object_repository.find(args['in'].to_s), + message: ComplaintMessage.new(args['message']), + description: args['description'] || '' ) end end diff --git a/app/builders/institution_builder.rb b/app/builders/institution_builder.rb index 2d1fa5a19a235559d133750307a499f85cdd1c21..d71072fa20aa041ead6da76626f067b3bd735f4b 100644 --- a/app/builders/institution_builder.rb +++ b/app/builders/institution_builder.rb @@ -5,39 +5,22 @@ class InstitutionBuilder < Builder # receive a list of ids and return a list of institutions # def self.build(institutions = []) - array = [] - institutions = [institutions] if institutions.class == String - institutions.each do |institution| - unless institution['@rid'].blank? - o = Rails.cache.fetch(cache_key(institution['@rid'], institution['last_modified'])) unless institution['last_modified'].blank? - o = institution_repository.find institution['@rid'] if o.nil? - array << o - end - end - array + super(institution_repository, institutions) end def self.build_from_orientdb(args = {}) - institution = nil - - unless args.nil? - # cache object when build - institution = Rails.cache.fetch(cache_key(args['@rid'], args['last_modified']), expires_in: 12.hours) do - Institution.new( - id: args['@rid'], - name: args['name'], - created_at: args['created_at'], - last_modified: args['last_modified'], - country: args['country'] || '', - city: args['city'] || '', - description: args['description'] || '', - thumbnail: args['thumbnail'] || '', - address: args['address'] || '' - ) - end - end - - institution + super(args) + Institution.new( + id: args['@rid'], + name: args['name'], + created_at: args['created_at'], + last_modified: args['last_modified'], + country: args['country'] || '', + city: args['city'] || '', + description: args['description'] || '', + thumbnail: args['thumbnail'] || '', + address: args['address'] || '' + ) end end diff --git a/app/builders/learning_object_builder.rb b/app/builders/learning_object_builder.rb index 4cdcf9a75438b195a5891987b055b2377483e338..cc23cb760531803c0985ed60c00a28223b528687 100644 --- a/app/builders/learning_object_builder.rb +++ b/app/builders/learning_object_builder.rb @@ -6,45 +6,28 @@ class LearningObjectBuilder < Builder # useful for search pagination # def self.build(objects = []) - lo = [] - objects = [objects] if objects.class == String || objects.class == Hash - objects.each do |object| - unless object['rid'].blank? - o = Rails.cache.fetch(cache_key(object['rid'], object['last_modified'])) unless object['last_modified'].blank? - o = learning_object_repository.find object['rid'] if o.nil? - lo << o - end - end - lo + super(learning_object_repository, objects, true, 'rid') end def self.build_from_orientdb(args = {}) - lo = nil - - unless args.nil? - # cache object when build - lo = Rails.cache.fetch(cache_key(args['@rid'], args['last_modified']), expires_in: 12.hours) do - args['metadata'] = JSON.parse(args['metadata']) if args['metadata'].class == String - obj = LearningObject.new( - - id: args['@rid'], - name: args['name'], - description: args['description'], - thumbnail: (args['thumbnail'] or ''), - id_dspace: args['id_dspace'], - type: args['type'], - attachment: LearningObject::Attachment.new(args['bitstreams']), - last_modified: args['last_modified'], - metadata: args['metadata'] - ) - obj.created_at = DateTime.strptime(args['created_at'], "%Y-%m-%d %H:%M:%S") unless args['created_at'].blank? - obj.last_modified = DateTime.strptime(args['last_modified'], "%Y-%m-%d %H:%M:%S") unless args['last_modified'].blank? - obj.published_at = DateTime.strptime(args['published_at'], "%Y-%m-%d %H:%M:%S") unless args['published_at'].blank? - obj - end + super(args) do + args['metadata'] = JSON.parse(args['metadata']) if args['metadata'].class == String + obj = LearningObject.new( + id: args['@rid'], + name: args['name'], + description: args['description'], + thumbnail: (args['thumbnail'] or ''), + id_dspace: args['id_dspace'], + type: args['type'], + attachment: LearningObject::Attachment.new(args['bitstreams']), + last_modified: args['last_modified'], + metadata: args['metadata'] + ) + obj.created_at = DateTime.strptime(args['created_at'], "%Y-%m-%d %H:%M:%S") unless args['created_at'].blank? + obj.last_modified = DateTime.strptime(args['last_modified'], "%Y-%m-%d %H:%M:%S") unless args['last_modified'].blank? + obj.published_at = DateTime.strptime(args['published_at'], "%Y-%m-%d %H:%M:%S") unless args['published_at'].blank? + obj end - - lo end end diff --git a/app/builders/subject_builder.rb b/app/builders/subject_builder.rb index b5fd7a1e328efde3bf064e26f5ae7794701bb868..6054f423f8aa53584f56e408e48ef0da79212d75 100644 --- a/app/builders/subject_builder.rb +++ b/app/builders/subject_builder.rb @@ -9,34 +9,18 @@ class SubjectBuilder < Builder # subjects = SubjectBuilder.build [{'@rid' => '#15:135'}, {'@rid' => '#15:140'}, {'@rid' => '#15:136'}] # subjects = SubjectBuilder.build [{'@rid' => '#15:135', 'last_modified' => '2015-30-10 15:44:12'}, {'@rid' => '#15:140'}, {'@rid' => '#15:136'}] def self.build(subjects = []) - array = [] - subjects = [subjects] if subjects.class == String - subjects.each do |subject| - unless subject['@rid'].blank? - o = Rails.cache.fetch(cache_key(subject['@rid'], subject['last_modified'])) unless subject['last_modified'].blank? - o = subject_repository.find subject['@rid'] if o.nil? - array << o - end - end - array + super(subject_repository, subjects) end def self.build_from_orientdb(args = {}) - subject = nil - - unless args.nil? - # cache object when build - subject = Rails.cache.fetch(cache_key(args['@rid'], args['last_modified']), expires_in: 12.hours) do - Subject.new( - id: args['@rid'], - name: args['name'], - created_at: args['name'], - last_modified: args['name'] - ) - end + super(args) do + Subject.new( + id: args['@rid'], + name: args['name'], + created_at: args['name'], + last_modified: args['name'] + ) end - - subject end end diff --git a/app/controllers/complaints_controller.rb b/app/controllers/complaints_controller.rb index b4b2039369b8612f96ffa64b447397bfd29e6be0..4177d7e9f336c20d346bbf1bb23bee68faa10c1a 100644 --- a/app/controllers/complaints_controller.rb +++ b/app/controllers/complaints_controller.rb @@ -4,7 +4,7 @@ class ComplaintsController < ApplicationController def create @complaint = Complaint.new(complaint_params) - @complaint.user = current_user + @complaint.user = current_user respond_to do |format| if complaint_repository.report @complaint diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index d51d3657f2d5b2c09540c41d7d7b893069f47d37..c4586e395fdd5e1c1a9a4b3a8035d4f5d25ef9f7 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -77,7 +77,7 @@ class LearningObjectsController < ApplicationController @learning_object.created_at = Time.now @learning_object.last_modified = Time.now @learning_object.publisher = current_user - @learning_object.metadata = lo.to_h[:metadata].as_json.to_s.gsub! '=>', ':' + @learning_object.metadata = lo.to_h[:metadata] @learning_object.attachment = LearningObject::Attachment.new([bitstream_response]) respond_to do |format| diff --git a/app/controllers/management/statistics_controller.rb b/app/controllers/management/statistics_controller.rb index de7f7136763003973b109344f725ea8193c1d9f4..d5f45bf0477a4bc2e3468cd43a1686aefb1a1683 100644 --- a/app/controllers/management/statistics_controller.rb +++ b/app/controllers/management/statistics_controller.rb @@ -1,17 +1,44 @@ class Management::StatisticsController < ManagementController include RepositoriesProxy + #before_action :set_statistics + before_action :authenticate_user!, except: [:index, :show, :like] + + #inicialização, primeira query + @@flag = 0 def index - @n_collections = collection_repository.get_number_of_collections - @n_views = main_page_repository.get_number_of("Views") - @n_users = subject_repository.get_number_of("User") - @n_learning_objects = learning_object_repository.get_number_of("learningObject") - @n_non_visualised = learning_object_repository.get_number_of_non_visualised + #a cada novo login atualiza as estatÃsticas + if @@flag == 0 || @@user != current_user + @@user = current_user + set_statistics + @@flag = 1 + end + + @n_users = @@n_users + @n_collections = @@n_collections + @n_non_visualised = @@n_non_visualised + @n_learning_objects = @@n_learning_objects + @total_accesses= User.sum("sign_in_count") end def users #missing roles - @n_users = subject_repository.get_number_of("User") + @n_users = User.count + @n_curators = 0 + @n_admins = 0 + @n_teachers = 0 + User.includes(:roles).all.each do |u| + if !u.roles[0].nil? + if u.roles[0]["name"] == "curator" + @n_curators += 1 + elsif u.roles[0]["name"] == "admin" + @n_admins += 1 + elsif u.roles[0]["name"] == "teacher" + @n_teachers +=1 + end + end + end + end def downloads @@ -20,20 +47,46 @@ class Management::StatisticsController < ManagementController def accesses #usar o logstash e kibana + #enquanto isso, uso o sign_in_count do ActiveRecord + @total_accesses= User.sum("sign_in_count") + + end def collections - @n_collections = collection_repository.get_number_of_collections + if @@flag == 0 || @@user != current_user + @@user = current_user + set_statistics + @@flag = 1 + end + @n_collections = @@n_collections || [] end + def learning_objects - @n_learning_objects = learning_object_repository.get_number_of("learningObject") - @n_non_visualised = learning_object_repository.get_number_of_non_visualised - @most_visualised = learning_object_repository.get_most_visualised + if @@flag == 0 || @@user != current_user + @@user = current_user + @@flag = 1 + set_statistics + end + @n_learning_objects = @@n_learning_objects + @most_visualised = @@most_visualised + @n_non_visualised = @@n_non_visualised + end + + def set_statistics + @@n_users = User.count + @@n_collections = collection_repository.get_number_of_collections || [] + @@n_learning_objects = learning_object_repository.count_all || [] + @@n_non_visualised = learning_object_repository.get_number_of_non_visualised || [] + @@most_visualised = learning_object_repository.get_most_visualised || [] + @@n_views = learning_object_repository.get_number_of("Views") || [] + end + def views - @n_views = main_page_repository.get_number_of("Views") + end end diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index d223f2f71cba133a87bd1d3a1207b1b5dda04bb3..73bdc0ff6cab056350dba03b882e2ce658f69068 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -77,7 +77,7 @@ class Management::UsersController < ManagementController @users = User.includes(:roles).all @users.all.each do |user| if !user.roles[0].nil? - @curators << user if user.roles[0].name == "curator" || [] + @curators << user unless !(user.roles[0].name == "curator") end end end @@ -87,7 +87,7 @@ class Management::UsersController < ManagementController @users = User.includes(:roles).all @users.all.each do |user| if !user.roles[0].nil? - @admins << user if user.roles[0].name == "admin" || [] + @admins << user unless !(user.roles[0].name == "admin") end end end diff --git a/app/repositories/orient_db/learning_object_repository.rb b/app/repositories/orient_db/learning_object_repository.rb index ce8cb1ccbf5a820cf1f109a23a110f9858733353..25051f15a2f6a8104c6c5edb2795b5910a3128fb 100644 --- a/app/repositories/orient_db/learning_object_repository.rb +++ b/app/repositories/orient_db/learning_object_repository.rb @@ -7,12 +7,12 @@ module OrientDb #get the ten most visualised. It's probably making too many useless accesses to orientDB... def get_most_visualised - result = connection.query("SELECT FROM (SELECT @rid,in('Views').size() AS views FROM LearningObject) ORDER BY views DESC LIMIT 10") - most_visualised = [] - result.each do |result| - most_visualised.push(get_by_rid(result["rid"])) - end - build_objects most_visualised + result = connection.query("SELECT FROM (SELECT name, @rid,in('Views').size() AS views FROM LearningObject) ORDER BY views DESC LIMIT 10") + #most_visualised = [] + #result.each do |result| + # most_visualised.push(get_by_rid(result["rid"])) + #end + #build_objects most_visualised end def get_publisher(learning_object) @@ -23,7 +23,7 @@ module OrientDb if result["@class"] == "Institution" institution_repository.build_object(result) else - user_repository.build_object(result) + user_repository.find(result['p_id']) end end end diff --git a/app/views/learning_objects/_form.html.erb b/app/views/learning_objects/_form.html.erb index 5dba470a9eb881730dd1395d650c9ca61f3fed36..8ea22a049d5b0e9eec39dada853c4c8613091adb 100644 --- a/app/views/learning_objects/_form.html.erb +++ b/app/views/learning_objects/_form.html.erb @@ -46,8 +46,9 @@ <%= f.file_field :file %> <br> <br> - <%= f.submit %> + <%= f.submit 'Criar Objeto'%> </fieldset> + <%= link_to "Voltar", me_users_path %> </div> </div> </div> diff --git a/app/views/learning_objects/show.html.erb b/app/views/learning_objects/show.html.erb index b563888f8da704e7e064e11efb9424b8fcfcbebc..6570547ed325b38104d0f0f13f5cc09dc08b8cd8 100644 --- a/app/views/learning_objects/show.html.erb +++ b/app/views/learning_objects/show.html.erb @@ -23,13 +23,26 @@ </div> <div class="col-md-5"> <div class="rightbar"> + <% author = @learning_object.get_metadata_value_of("dc.contributor.author") %> + <% unless author.blank? %> + <div class="media"> + <div class="media-left"> + <a href="#"><img class="user-image-small" src="<%#= current_user.avatar.url(:thumb) %><%= asset_path('user-anon.png')%>" alt="Foto do usuário"/></a> + </div> + <div class="media-body"> + <h5>Autor</h5> + <h3 class="media-heading"><%= author %></h3> + </div> + </div> + <% end %> <div class="media"> <div class="media-left"> <a href="#"><img class="user-image-small" src="<%#= current_user.avatar.url(:thumb) %><%= asset_path('user-anon.png')%>" alt="Foto do usuário"/></a> </div> <div class="media-body"> - <h5>Adicionado por</h5> - <h3 class="media-heading"><%= @learning_object.get_metadata_value_of("dc.contributor.author") %></h3> + <% publisher_type = @learning_object.publisher.class %> + <h5><%= publisher_type == User ? 'Adicionado por' : 'Origem'%></h5> + <h3 class="media-heading"><%= @learning_object.publisher.name %></h3> </div> </div> <div class="rating-panel"> diff --git a/app/views/management/complaints/index.html.erb b/app/views/management/complaints/index.html.erb index 85938c556159b61535d77f92aab99ff9419903f6..06f887f24c0affb1ed25c3221f9cdee966104c43 100644 --- a/app/views/management/complaints/index.html.erb +++ b/app/views/management/complaints/index.html.erb @@ -106,7 +106,7 @@ <div class="ls-list-content "> <div class="col-xs-12 col-md-6"> <span class="ls-list-label">Denunciado por</span> - <strong><%= complaint.user.name %></strong> + <strong><%= complaint.user.name unless complaint.user.nil?%></strong> </div> <div class="col-xs-12 col-md-6"> <span class="ls-list-label">Data</span> @@ -121,4 +121,4 @@ </div> -</div> \ No newline at end of file +</div> diff --git a/app/views/management/statistics/accesses.html.erb b/app/views/management/statistics/accesses.html.erb index 24f59d864c6fb3dcb903bf749b55e50636a8342d..b5fe4f206ae55f39d345387d26cf6bce91b66f32 100644 --- a/app/views/management/statistics/accesses.html.erb +++ b/app/views/management/statistics/accesses.html.erb @@ -14,13 +14,17 @@ <div id="sending-stats" class="row"> <div class="col-sm-6 col-md-12"> <div class="ls-box"> - <h6 class="ls-title-6">Total</h6> - <strong class="ls-color-theme">2091</strong> + <h6 class="ls-title-6">Total de acessos dos usuários</h6> + <strong class="ls-color-theme"><%= @total_accesses %></strong> </div> </div> </div> </div> + + +<!-- Gráfico ainda não populado <div align="center"> <canvas id="accesses" width="400" height="350"></canvas> </div> +--> diff --git a/app/views/management/statistics/collections.html.erb b/app/views/management/statistics/collections.html.erb index 0da808d5194434ad0e7d93f9d1709fae529f9286..786b26840d2babf02dd337636ad3749a62f5e93b 100644 --- a/app/views/management/statistics/collections.html.erb +++ b/app/views/management/statistics/collections.html.erb @@ -14,7 +14,7 @@ <div class="col-sm-6 col-md-12"> <div class="ls-box"> <h6 class="ls-title-6">Total</h6> - <strong class="ls-color-theme">348</strong> + <strong class="ls-color-theme"><%= @n_collections %></strong> </div> </div> </div> @@ -25,7 +25,9 @@ Por Ãrea do conhecimento </div> <br> +<!-- Gráfico ainda não populado <div align="center"> <canvas id="colections" width="400" height="350"></canvas> </div> +--> diff --git a/app/views/management/statistics/index.html.erb b/app/views/management/statistics/index.html.erb index 3868c0e0af441262ecd2c9017d2feb581e13ecfa..2d96a3ee5879dc154660b1989cb635dd926162de 100644 --- a/app/views/management/statistics/index.html.erb +++ b/app/views/management/statistics/index.html.erb @@ -39,8 +39,8 @@ </div> <div class="col-sm-6 col-md-3"> <div class="ls-box"> - <h6 class="ls-title-4 ">Objetos não visualizados</h6> - <strong class="ls-color-theme"><%= @n_non_visualised %></strong> + <h6 class="ls-title-4 ">Acessos</h6> + <strong class="ls-color-theme"><%= @total_accesses %></strong> <%= link_to "Mais detalhes" , accesses_management_statistics_path, class: "ls-btn ls-btn-sm" %> </div> diff --git a/app/views/management/statistics/learning_objects.html.erb b/app/views/management/statistics/learning_objects.html.erb index dfdbe98e489d0912f280a2c8cb6e09a6c0f028d7..999870e07de6c60c307478b9c926e4957adaaae6 100644 --- a/app/views/management/statistics/learning_objects.html.erb +++ b/app/views/management/statistics/learning_objects.html.erb @@ -36,10 +36,13 @@ </div> </div> + + <input type="hidden" id="lobject" value="<%= @n_learning_objects - @n_non_visualised %>"/> <input type="hidden" id="lobject_non" value="<%= @n_non_visualised %>"/> + <div> <div style="float: left; margin-left: 85px; margin-top: 100px"> <canvas id="learning_objects" width="700" height="600"></canvas> @@ -49,7 +52,8 @@ <h3><th><b> 10 mais visualisados </b></th></h3><br> <div class="row learning-object-columns"> <% @most_visualised.each do |most| %> - <%= render_learning_object("vertical", most) %> + <%#= render_learning_object("vertical", most) %> + <li><%= link_to most["name"], learning_object_path(most["@rid"]) %></li><BR> <% end %> </div> </div> diff --git a/app/views/management/statistics/users.html.erb b/app/views/management/statistics/users.html.erb index 237fd288d86516e4dcb0e487d270c6ef1034a235..0956e47123042f8bd27093926bdd3e865c5bc3f9 100644 --- a/app/views/management/statistics/users.html.erb +++ b/app/views/management/statistics/users.html.erb @@ -14,53 +14,35 @@ <div class="col-sm-6 col-md-12"> <div class="ls-box"> <h6 class="ls-title-6">Total</h6> - <strong class="ls-color-theme">70</strong> + <strong class="ls-color-theme"><%=@n_users%></strong> <!--<small>envios por mês</small>--> <%#= link_to "Mais detalhes" , management_statistics_users_path, class: "ls-btn ls-btn-sm" %> </div> </div> - <div class="col-sm-6 col-md-3"> - <div class="ls-box"> - <h6 class="ls-title-4">Estudantes</h6> - <strong class="ls-color-theme">20</strong> - <%#= link_to "Mais detalhes" , management_statistics_colections_path, class: "ls-btn ls-btn-sm" %> - </div> - </div> - <div class="col-sm-6 col-md-2"> + + <div class="col-sm-6 col-md-4"> <div class="ls-box"> <h6 class="ls-title-4">Professores</h6> - <strong class="ls-color-theme">42</strong> + <strong class="ls-color-theme"><%=@n_teachers%></strong> <%#= link_to "Mais detalhes" , management_statistics_downloads_path, class: "ls-btn ls-btn-sm" %> </div> </div> - <div class="col-sm-6 col-md-2"> + <div class="col-sm-6 col-md-4"> <div class="ls-box"> <h6 class="ls-title-4 ">Curadores</h6> - <strong class="ls-color-theme">4</strong> + <strong class="ls-color-theme"><%=@n_curators%></strong> <%#= link_to "Mais detalhes" , management_statistics_acessos_path, class: "ls-btn ls-btn-sm" %> </div> </div> - - - - <div class="col-sm-6 col-md-2"> - <div class="ls-box"> - <h6 class="ls-title-4 ">Moderadores</h6> - <strong class="ls-color-theme">3</strong> - - <%#= link_to "Mais detalhes" , management_statistics_acessos_path, class: "ls-btn ls-btn-sm" %> - </div> - </div> - - <div class="col-sm-6 col-md-3"> + <div class="col-sm-6 col-md-4"> <div class="ls-box"> <h6 class="ls-title-4 ">Administradores</h6> - <strong class="ls-color-theme">1</strong> + <strong class="ls-color-theme"><%=@n_admins%></strong> </div> </div> @@ -81,6 +63,9 @@ </div> </div> +<input type="hidden" id="n_teachers" value="<%= @n_teachers %>"/> +<input type="hidden" id="n_curators" value="<%= @n_curators %>"/> +<input type="hidden" id="n_admins" value="<%= @n_admins %>"/> <div align="center"> <canvas id="users" width="400" height="350"> </canvas> diff --git a/app/views/management/users/admins.html.erb b/app/views/management/users/admins.html.erb index 438ac734ec8c7224d08da60454733fc5364e2866..da1f1e1101db4e3fe3110a71c3d47e53ed1e70d8 100644 --- a/app/views/management/users/admins.html.erb +++ b/app/views/management/users/admins.html.erb @@ -44,12 +44,18 @@ </tr> </thead> <tbody> - + <% @admins.each do |c| %> <tr> <td> <a href="#"><%= c.name %></a> - <span class="ls-tag hidden-xs"><%= c.roles[0].name %></span> + <% nome = case c.roles[0].name + when "teacher" then "Professor" + when "admin" then "Administrador" + when "curator" then "Curador" + end %> + <span class="ls-tag hidden-xs"><%= nome %></span> + </td> </td> <td class="ls-txt-center hidden-xs"> <small class="ls-display-block"><b>Último acesso:</b> <%= c.current_sign_in_at.to_date %></small> @@ -65,7 +71,12 @@ <a href="#" class="ls-btn ls-btn-sm" aria-expanded="false" role="combobox">NÃvel</a> <ul class="ls-dropdown-nav" aria-hidden="true"> <% Role.all.each do |r| %> - <li><%= link_to "Definir como #{r.name}", change_roles_management_user_path(:id => c.id, :role_id => r.id), :method => :post %></li> + <% nome = case r.name + when "teacher" then "Professor" + when "admin" then "Administrador" + when "curator" then "Curador" + end %> + <li><%= link_to "Definir como #{nome}", change_roles_management_user_path(:id => c.id, :role_id => r.id), :method => :post %></li> <% end %> </ul> </div> diff --git a/app/views/management/users/curators.html.erb b/app/views/management/users/curators.html.erb index 49f01b08b594b455f91a1a3de157895cebc51475..31fcc19e157b505edcff8c46fe0630b2d97cc252 100644 --- a/app/views/management/users/curators.html.erb +++ b/app/views/management/users/curators.html.erb @@ -50,7 +50,12 @@ <tr> <td> <a href="#"><%= c.name %></a> - <span class="ls-tag hidden-xs"><%= c.roles[0].name %></span> + <% nome = case c.roles[0].name + when "teacher" then "Professor" + when "admin" then "Administrador" + when "curator" then "Curador" + end %> + <span class="ls-tag hidden-xs"><%= nome %></span> </td> <td class="ls-txt-center hidden-xs"> <small class="ls-display-block"><b>Último acesso:</b> <%= c.current_sign_in_at.to_date %></small> @@ -66,7 +71,12 @@ <a href="#" class="ls-btn ls-btn-sm" aria-expanded="false" role="combobox">NÃvel</a> <ul class="ls-dropdown-nav" aria-hidden="true"> <% Role.all.each do |r| %> - <li><%= link_to "Definir como #{r.name}", change_roles_management_user_path(:id => c.id, :role_id => r.id), :method => :post %></li> + <% nome = case r.name + when "teacher" then "Professor" + when "admin" then "Administrador" + when "curator" then "Curador" + end %> + <li><%= link_to "Definir como #{nome}", change_roles_management_user_path(:id => c.id, :role_id => r.id), :method => :post %></li> <% end %> </ul> </div> diff --git a/app/views/management/users/index.html.erb b/app/views/management/users/index.html.erb index c6f8c2cee8564ae81a5951e82b3d6377de1f3eeb..6c639afb7b75eb131aa6474e03630f63340fd643 100644 --- a/app/views/management/users/index.html.erb +++ b/app/views/management/users/index.html.erb @@ -47,7 +47,13 @@ <a href="#"><%= u.name %></a> <% u.roles.each do |r| %> - <span class="ls-tag hidden-xs"><%= r.name %></span> + <% nome = case u.roles[0].name + when "teacher" then "Professor" + when "admin" then "Administrador" + when "curator" then "Curador" + end %> + <span class="ls-tag hidden-xs"><%= nome %></span> + </td> <% end %> </td> @@ -68,7 +74,12 @@ <ul class="ls-dropdown-nav"> <% @user = u %> <% Role.all.each do |r| %> - <li><%= link_to "Definir como #{r.name}", change_roles_management_user_path( :id => u, :role_id => r.id),:method => :post %></li> + <% nome = case r.name + when "teacher" then "Professor" + when "admin" then "Administrador" + when "curator" then "Curador" + end %> + <li><%= link_to "Definir como #{nome}", change_roles_management_user_path( :id => u, :role_id => r.id),:method => :post %></li> <% end %> </ul> </div> diff --git a/app/views/shared/application/_header.html.erb b/app/views/shared/application/_header.html.erb index 46ef6ac2515bff0c28d736665d6eeb286531d962..c94bdbf9417c4ca23b489cfff5cec53ab5585488 100644 --- a/app/views/shared/application/_header.html.erb +++ b/app/views/shared/application/_header.html.erb @@ -84,6 +84,10 @@ <a class="nav-dropdown" data-content="about" href="javascript:void(0);">Sobre <span class="caret"/></a> </h3></li> <li role="separator" class="divider"></li> + <li class="nav-button"><h3> + <%= link_to "Enviar Novo Item", new_learning_object_path, style: "color: #2178F5" %> + </h3></li> + <li role="separator" class="divider"></li> </ul> </div> </div>