diff --git a/app/controllers/concerns/paginator.rb b/app/controllers/concerns/paginator.rb
index af015ff08cf386bb3a8a6fff7f96e8a8567cfe90..b921923444853fb9fe9a87942eaddc62fa404f39 100644
--- a/app/controllers/concerns/paginator.rb
+++ b/app/controllers/concerns/paginator.rb
@@ -27,6 +27,12 @@ module Paginator
     return model[offset..limit]
   end
 
+  #return paginate for select queries
+  def paginate_select(model, total)
+    total_count_select total
+    return model
+  end
+  
   private
 
     def limit
@@ -66,5 +72,8 @@ module Paginator
     def total_count(model)
       headers['X-Total-Count'] = model.count
     end
-
+    
+    def total_count_select(total)
+      headers['X-Total-Count'] = total
+    end
 end
diff --git a/app/controllers/v1/complaint_votes_controller.rb b/app/controllers/v1/complaint_votes_controller.rb
index 9a158ddf332e09dfc67c61f1365872e49252d0d3..af971d16e881423b7631fba62d20653d5c0b4efd 100644
--- a/app/controllers/v1/complaint_votes_controller.rb
+++ b/app/controllers/v1/complaint_votes_controller.rb
@@ -1,3 +1,22 @@
+
+# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
+# Departamento de Informatica - Universidade Federal do Parana
+#
+# This file is part of portalmec.
+#
+# portalmec is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# portalmec is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
+
 class V1::ComplaintVotesController < ApplicationController
     include ::DeletedObjectsController
     include ::Paginator
@@ -16,31 +35,20 @@ class V1::ComplaintVotesController < ApplicationController
 
     # POST /v1/complaint_votes
     def create
-        @complaint_vote = ComplaintVote.where(complainable_id: params[:complainable_id]).first
-
-        # if object does not exists create
-        if @complaint_vote.blank?
-            @complaint_vote = ComplaintVote.new(complaint_vote_params)
+        @complaint_vote = ComplaintVote.new(complaint_vote_params)
 
-            if @complaint_vote.save
-                render json: @complaint_vote, status: :created
-            else
-                render json: @complaint_vote.errors, status: :unprocessable_entity
-            end
-        # if object already exists update the pros and cons votes by addding the new vote on the current votes 
+        if @complaint_vote.save
+            render json: @complaint_vote, status: :created
         else
-            vote_pros = @complaint_vote.pros + params[:pros]
-            vote_cons = @complaint_vote.cons + params[:cons]
-
-            @complaint_vote.update(pros: vote_pros, cons: vote_cons)
-            
-            verify_votes(@complaint_vote)
+            render json: @complaint_vote.errors, status: :unprocessable_entity
         end
+        
+        verify_votes(@complaint_vote)
     end
 
     # Set the params required for creating a complaint vote
     def complaint_vote_params
-        params.require(:complaint_vote).permit(:complainable_type, :complainable_id, :pros, :cons)
+        params.require(:complaint_vote).permit(:complainable_type, :complainable_id, :pros, :cons, :user_id)
     end
 
     # PUT/PATCH /v1/complaint_votes/{id}
@@ -60,24 +68,45 @@ class V1::ComplaintVotesController < ApplicationController
     end
 
     def set_complaint_vote
-        @complaint_vote = ComplaintVote.where(id: params[:id]).first
+        # @complaint_vote = ComplaintVote.where(id: params[:id]).first
         
-        render status: :not_found if @complaint_vote.blank?
+        # render status: :not_found if @complaint_vote.blank?
         
-        @complaint_vote
+        # @complaint_vote
+
+        @complaint_vote ||= ComplaintVote.find_by_id(params[:id]).first
+        if @complaint_vote.blank?
+            render status: :not_found
+        end
     end
     
     # if the difference between the pros and cons votes is more than 2, destroy the learning object  
     def verify_votes(complaint_vote)
-        if complaint_vote.pros - complaint_vote.cons > 2
-            LearningObject.find_by_id(complaint_vote.complainable_id).destroy
-            Complaint.find_by_complainable_id(complaint_vote.complainable_id).destroy
-            ComplaintVote.find_by_complainable_id(complaint_vote.complainable_id).destroy
-        elsif complaint_vote.cons - complaint_vote.pros > 2
-            @current_complaint = Complaint.where(complainable_id: @complaint_vote.complainable_id).first
-            @current_complaint.update(deleted_at: Time.now)
-            ComplaintVote.find_by_complainable_id(complaint_vote.complainable_id).destroy
+
+        data = ComplaintVote.select("complainable_id, sum(pros) as pros, sum(cons) as cons")
+                            .where("complainable_id = ?", complaint_vote.complainable_id)
+                            .group("complaint_votes.complainable_id")
+
+        data.each do |d|
+            if (d.complainable_id == complaint_vote.complainable_id)
+                if d.pros - d.cons > 2
+                    ComplaintVote.where("complainable_id = ?", complaint_vote.complainable_id).destroy_all
+                    Complaint.where("complainable_id = ?", complaint_vote.complainable_id).destroy_all
+                    LearningObject.where(id: complaint_vote.complainable_id).update_all(deleted_at: Time.now)
+                    #Complaint.find_by_complainable_id(complaint_vote.complainable_id).update(state: 2)
+                    #Complaint.find_by_complainable_id(complaint_vote.complainable_id).destroy
+                    #ComplaintVote.find_by_complainable_id(complaint_vote.complainable_id).destroy
+                    #LearningObject.find_by_id(complaint_vote.complainable_id).destroy
+                    # puts "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
+                    # puts "  pros maior que cons, pros = #{d.pros}, cons = #{d.cons}"
+                    # puts "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
+                elsif d.cons - d.pros > 2
+                    ComplaintVote.where("complainable_id = ?", complaint_vote.complainable_id).destroy_all
+                    Complaint.where("complainable_id = ?", complaint_vote.complainable_id).update_all(state: Complaint.states[:rejected])
+                    LearningObject.where(id: complaint_vote.complainable_id).update_all(state: LearningObject.states[:published])
+                end
+            end
         end
     end
 
-end
\ No newline at end of file
+end
diff --git a/app/controllers/v1/complaints_controller.rb b/app/controllers/v1/complaints_controller.rb
index 16ca72fb7b6d86e004583e37d557585772d0fa69..0931bbfb974e6ade913946f784e4aed7b57b02ca 100644
--- a/app/controllers/v1/complaints_controller.rb
+++ b/app/controllers/v1/complaints_controller.rb
@@ -54,7 +54,9 @@ class V1::ComplaintsController < ApplicationController
     if @complaint.save
       ComplaintsMailer.new_complaint_received(@complaint, @current_user).deliver_now
       
-      @complaint.complainable.treat_complaintment
+      if (Complaint.where(complainable_id: @complaint.complainable_id).count >= 2)
+        LearningObject.where(id: @complaint.complainable_id).update_all(state: LearningObject.states[:suspended])
+      end
       
       render json: @complaint, status: :created
     else
diff --git a/app/controllers/v1/learning_objects_complaints_controller.rb b/app/controllers/v1/learning_objects_complaints_controller.rb
index 372f60d6a5212bc0d560f0788475b957114717ed..a44b8afe8be401703816537bd218fbd58520fc11 100644
--- a/app/controllers/v1/learning_objects_complaints_controller.rb
+++ b/app/controllers/v1/learning_objects_complaints_controller.rb
@@ -3,28 +3,105 @@ class V1::LearningObjectsComplaintsController < ApplicationController
     include ::DeletedObjectsController
     include ::Paginator
 
-    before_action :set_complaint, only: [:show, :show_related , :reject, :accept]
+    # learning_object_complaints[i] = data of a complaint (always in even positions)
+    # learning_object_complaints[i+1] = image of learning_object, and user, also contains the tags of the object and the download link (always in odd positions)
 
-    # GET v1/learning_objects_complaints
-    def index
-        complaints_curator = paginate Complaint
+    def generate_priority_queue(complaints_priority)
 
-        base_date = Date.new(2022, 1, 1)
-
-        complaints_priority = ComplaintReason.joins(:complaints).select("complainable_id, SUM(complaint_reasons.priority)")
-        .where("complaints.created_at >= ?", base_date).group("complainable_id").order("sum DESC")
-      
         complaints_curator = []
-        
         complaints_priority.each do |complainable|
 
             # Select all complaints related to the complainable_id (attributes that have been sumed)
-            complaints_curator << ComplaintReason.joins(:complaints).select("*")
-            .where("complaints.complainable_id = ? AND complaints.created_at >=?", complainable.complainable_id, base_date).order("complaint_reasons.priority DESC")
+            complaints_curator << ComplaintReason.joins("INNER JOIN complaints ON complaint_reasons.id = complaints.complaint_reason_id 
+                 INNER JOIN learning_objects on complaints.complainable_id = learning_objects.id
+                 INNER JOIN users ON learning_objects.publisher_id = users.id 
+                 INNER JOIN object_types ON learning_objects.object_type_id = object_types.id
+                 ")
+                .select("learning_objects.id as learning_object_id, learning_objects.name, learning_objects.review_average, 
+                    learning_objects.likes_count, users.name as publisher_name,
+                    object_types.name as type_object, complaints.description, complaint_reasons.id as complaint_reason_id, 
+                    complaint_reasons.reason, complaint_reasons.priority")
+                .where("complaints.complainable_id = ? AND complaints.state = 0", complainable.complainable_id).order("complaint_reasons.priority DESC")
+
+            #find the learning_object by the complainable_id
+            learning_object = LearningObject.where(id: complainable.complainable_id)
+            
+            lo_data = Hash.new
+
+            tags = Tagging.joins(:tag).where("taggings.taggable_id = ?", complainable.complainable_id).select("tags.name")
+            all_tags = []
+
+            #add all tags to lo_data hash
+            tags.each do |tag|
+                if (tag.name != nil)
+                    all_tags << tag.name
+                end
+            end
+
+            lo_data['tags'] = all_tags
+            
+            #iterate by all learning_objects found
+            for lo in learning_object
+                
+                lo_data['learning_object_thumb'] = lo.thumbnail
+                if (lo.publisher_id != nil) 
+                    user = User.where(id: lo.publisher_id).first
+                    lo_data['user_avatar'] = user.avatar
+                end
+                lo_data['download_link'] = lo.download_link
+
+            end
+
+            complaints_curator << lo_data
         end
+        
+        return complaints_curator
+        
+    end
 
-        render json: complaints_curator
+    # GET v1/learning_objects_complaints
+    def index
+                
+        
+        #select and sum the priority if has two or more complaints
+        complaints_priority = ComplaintReason.joins(:complaints).select("complainable_id, SUM(complaint_reasons.priority) as priorities")
+        .where("complaints.state = 0").group("complainable_id").having("(COUNT(complainable_id) > 1 OR SUM(complaint_reasons.priority) > 20)")
+        .order("priorities DESC").order("complainable_id").limit(params["limit"]).offset(params["offset"])
+        
+        total = ComplaintReason.joins(:complaints).select("complainable_id, SUM(complaint_reasons.priority)")
+        .where("complaints.state = 0").group("complainable_id").having("COUNT(complainable_id) > 1 OR SUM(complaint_reasons.priority) > 20")
+
+        queue = generate_priority_queue(complaints_priority)
+        complaints_queue = paginate_select(queue, total.length)
+
+        render json: complaints_queue
 
     end
 
-end
\ No newline at end of file
+    # GET v1/learning_objects_complaints/queue_user/:user_id
+    def queue_user
+        #select and sum the priority if has two or more complaints
+        complaints_priority = ComplaintReason.joins(:complaints).select("complainable_id, SUM(complaint_reasons.priority) as priorities")
+        .where("complaints.state = 0").where.not("complaints.user_id = ?",params[:user_id]).group("complainable_id").having("(COUNT(complainable_id) > 1 OR SUM(complaint_reasons.priority) > 20)")
+        .order("priorities DESC").order("complainable_id").limit(params["limit"]).offset(params["offset"])
+        
+        total = ComplaintReason.joins(:complaints).select("complainable_id, SUM(complaint_reasons.priority)")
+        .where("complaints.state = 0").where.not("complaints.user_id = ?",params[:user_id]).group("complainable_id").having("COUNT(complainable_id) > 1 OR SUM(complaint_reasons.priority) > 20")
+
+        queue = generate_priority_queue(complaints_priority)
+        complaints_queue = paginate_select(queue, total.length)
+
+        render json: complaints_queue
+
+    end
+    
+    def show
+        id = params[:id]
+        complaints = ComplaintReason.joins("INNER JOIN complaints ON complaint_reasons.id = complaints.complaint_reason_id")
+        .where("complaints.complainable_id = ?",id)
+        .select("complaints.description, complaint_reasons.reason, complaint_reasons.priority")
+        render json: complaints
+    end
+
+end
+
diff --git a/app/controllers/v1/submissions_controller.rb b/app/controllers/v1/submissions_controller.rb
index 6e717db34bfc02c95fadfd127d277d715b41c61e..d38fb01dfa75cc069fb0a863a92fe98f4a245fe6 100644
--- a/app/controllers/v1/submissions_controller.rb
+++ b/app/controllers/v1/submissions_controller.rb
@@ -20,13 +20,16 @@
 class V1::SubmissionsController < ApplicationController
   include ::Paginator
 
-  before_action :set_new_submission, only: :index
-  before_action :set_submission, only: [:show, :answer, :destroy]
+  before_action :set_new_submission , only: :index
+  before_action :set_submission , only: [:show, :answer, :destroy]
   before_action :authenticate_user!
-  before_action :authorize!, except: :create
+  before_action :authorize!, except: [:create, :user_submissions, :all_users_submissions]
 
   def index
+    
+
     submissions = paginate Submission.all
+  
     render json: submissions
   end
 
@@ -34,6 +37,19 @@ class V1::SubmissionsController < ApplicationController
     render json: @submission
   end
 
+  def user_submissions
+    submission_user = Submission.where(submitter_id: params[:user_id]).where(status: 0)
+    all_submission_user = paginate submission_user
+    render json: all_submission_user
+  end
+  
+  def all_users_submissions
+    # show all submissions of all users without from the current user
+    submissions_users = Submission.where(status: 0).where.not(submitter_id: params[:user_id])
+    all_submissions_users = paginate submissions_users
+    render json: all_submissions_users
+  end
+
   def create
     learning_object = LearningObject.where(id: submission_params[:learning_object_id]).first
     if learning_object.blank?
@@ -72,10 +88,9 @@ class V1::SubmissionsController < ApplicationController
       end
       @submission.curator = current_user
       if @submission.save
-        if @submission.accepted?
-          publisher = LearningObjectPublisher.new(DspaceService.create_client)
-          publisher.publish @submission.learning_object
-        else
+        if @submission.accepted?def user_submissions
+          render status: :ok
+        end
           @submission.learning_object.destroy
         end
         render json: @submission, status: :ok
@@ -118,4 +133,5 @@ class V1::SubmissionsController < ApplicationController
   def authorize!
     authorize @submission
   end
+
 end
diff --git a/app/controllers/v1/users_controller.rb b/app/controllers/v1/users_controller.rb
index 6d187234d92a7695830e0fd8976d5821d85de28f..d45e800378bbb4844e7e356775b9df979e6a0ba9 100644
--- a/app/controllers/v1/users_controller.rb
+++ b/app/controllers/v1/users_controller.rb
@@ -38,10 +38,12 @@ class V1::UsersController < ApplicationController
     # current_user completes an action
     # action counters and user progresses for achievements are updated,
     # and if an achievement was conquered its rewards are given
+    
     quantity = params[:quantity].to_i > 1 ? params[:quantity].to_i : 1
 
     success, response = current_user.complete_action(Action.where(id: params[:action_id]).first, quantity)
     status = success ? :ok : :unprocessable_entity
+    
 
     render json: response, status: status
   end
diff --git a/app/models/complaint_vote.rb b/app/models/complaint_vote.rb
index 364fad3560cb60de94cc7f254f0bc2813fc6bb96..c1bf5017a484d8b551312efe3318b6e9933c5734 100644
--- a/app/models/complaint_vote.rb
+++ b/app/models/complaint_vote.rb
@@ -1,9 +1,30 @@
+
+# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
+# Departamento de Informatica - Universidade Federal do Parana
+#
+# This file is part of portalmec.
+#
+# portalmec is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# portalmec is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
+
 class ComplaintVote < ApplicationRecord
     include Trackable
     belongs_to :complainable, polymorphic: true
 
-    validates_presence_of :complainable_id
-
+    belongs_to :user
+    validates_presence_of :user, :complainable_id
+    validates :user_id, uniqueness: { scope: [:complainable_id, :complainable_type]}
+    
     acts_as_paranoid
     has_paper_trail
 
diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb
index a1ca7445bd1235bcaa586691dc90aac9b9d98ae9..8695fd1cd149e462c15cf3c54fa338aa2c32d1f0 100644
--- a/app/models/learning_object.rb
+++ b/app/models/learning_object.rb
@@ -219,8 +219,9 @@ class LearningObject < ApplicationRecord
 
   def treat_complaintment
     #Uncomment the line below if an arbitrary number of complaints are necessary to suspend the LO.
-    # if (Complaint.where(complainable_id: @complaint.complainable_id).count < 5)
-    self.suspended!
+    if (Complaint.where(complainable_id: self.complainable_id).count >= 2)
+      LearningObject.find_by_id(self.complainable_id).update(state: 0);
+    end
   end
 
   def complaint_accept(params)
diff --git a/app/models/user.rb b/app/models/user.rb
index dac3fd8761dbf0090160048d1a94d6737236d38a..4516f5f9fa66d5ab567df5912b70f2fbd3b9b210 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -356,6 +356,12 @@ class User < ApplicationRecord
   def experience=(xp)
     new_level, remaining_xp = calculate_level(xp)
     self.level = new_level
+    
+    #if the new level is more than 5, give him curator role
+    if new_level >= 5 && !self.is_curator?
+      self.roles << Role.find_by(name: 'curator')
+    end
+
     super(remaining_xp)
   end
 
diff --git a/app/services/dspace_service.rb b/app/services/dspace_service.rb
index fd63e62d6f997a3d0aa5afb8d1cbadd91f8f1a6c..cac09e7e692316c5b7143cc9bc391b1707717f81 100644
--- a/app/services/dspace_service.rb
+++ b/app/services/dspace_service.rb
@@ -22,7 +22,7 @@ require 'dspace'
 class DspaceService
 
   # ID's of collections
-  TEST_COLLECTION = 4
+  TEST_COLLECTION = "b1ae8711-bb96-4dd2-945d-ea27ee1141db"
   PORTALMEC_COLLECTION = 3
   PORTALMEC_BETA_COLLECTION = 6
   BD_INT_OBJETOS_COLLECTION = 2
diff --git a/config/database.yml b/config/database.yml
index efe8ff8bba66a0ddb4282beca6915ad9b7294a48..abafacb352c3997be8b700c0c501d618f1064778 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -5,17 +5,18 @@
 development:
   adapter: postgresql
   encoding: unicode
-  database: portalmec_dev
-  username: arthur
-  password: senhadopostgres
+  database: portalmecapi
+  username: portalmec
+  password: 123mudar
+  host: localhost
 
 test:
   adapter: postgresql
   encoding: unicode
-  database: portalmec_test
-  username: arthur
-  password: senhadopostgres
-# host: postgres 
+  database: portalmecapi
+  username: portalmec
+  password: 123mudar
+  host: localhost
 
 production:
   adapter: postgresql
@@ -26,3 +27,4 @@ production:
   database: <%= ENV['PORTALMEC_DB_NAME'] %>
   username: <%= ENV['PORTALMEC_DB_USERNAME'] %>
   password: <%= ENV['PORTALMEC_DB_PASSWORD'] %>
+  reaping_frequency: 30
diff --git a/config/dspace.yml b/config/dspace.yml
index 6b221dce4cc5a7d67fae114cdd19f9a80d989717..023bdbc731a8277c33c5d9ce95332bfb0bb3fb61 100644
--- a/config/dspace.yml
+++ b/config/dspace.yml
@@ -19,11 +19,11 @@
 development:
   host: mecdb2.c3sl.ufpr.br
   port: 8443
-  login: admin
-  password: password
+  login: admin@mecdb3.c3sl.ufpr.br
+  password: admin
 
 test:
   host: mecdb2.c3sl.ufpr.br
   port: 8443
-  login: admin
-  password: password
\ No newline at end of file
+  login: admin@mecdb3.c3sl.ufpr.br
+  password: admin
diff --git a/config/env_vars.sh b/config/env_vars.sh
index afb846d897c92e66e672810de138cb34f5a95e70..008132b1a20ea9fcc7b4234b4951a6dcfd59b48c 100644
--- a/config/env_vars.sh
+++ b/config/env_vars.sh
@@ -18,35 +18,35 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
 
-export SECRET_TOKEN=$(rake secret)
-export SECRET_KEY_BASE=$(rake secret)
+#export SECRET_TOKEN=$(rake secret)
+#export SECRET_KEY_BASE=$(rake secret)
 
 ### Postgres/Active Record credentials
 export PORTALMEC_DB_HOST=localhost
 export PORTALMEC_DB_POOL=25
-export PORTALMEC_DB_NAME=portalmec
-export PORTALMEC_DB_USERNAME=
-export PORTALMEC_DB_PASSWORD=
+export PORTALMEC_DB_NAME=portalmecapi
+export PORTALMEC_DB_USERNAME=portalmec
+export PORTALMEC_DB_PASSWORD=123mudar
 
 ### Dspace credentials
-export PORTALMEC_DSPACE_LOGIN=
-export PORTALMEC_DSPACE_PASSWORD=
-export PORTALMEC_DSPACE_PORT=
-export PORTALMEC_DSPACE_HOST=
+export PORTALMEC_DSPACE_LOGIN=admin@mecdb3.c3sl.ufpr.br
+export PORTALMEC_DSPACE_PASSWORD=admin
+export PORTALMEC_DSPACE_PORT=8443
+export PORTALMEC_DSPACE_HOST=mecdb4.c3sl.ufpr.br
 
 ### Elasticsearch credentials
-export PORTALMEC_ELASTICSEARCH_LOGIN=
-export PORTALMEC_ELASTICSEARCH_PASSWORD=
-export PORTALMEC_ELASTICSEARCH_PORT=
-export PORTALMEC_ELASTICSEARCH_HOST=
+#export PORTALMEC_ELASTICSEARCH_LOGIN=
+#export PORTALMEC_ELASTICSEARCH_PASSWORD=
+export PORTALMEC_ELASTICSEARCH_PORT=9200
+export PORTALMEC_ELASTICSEARCH_HOST=localhost
 
 ### Cache
 export MEMCACHE_SERVERS=localhost
 
 ### SMTP
-export ACTION_MAILER_HOST=
-export SMTP_ADDRESS=
-export SMTP_PORT=
+export ACTION_MAILER_HOST=api.portalmec.c3sl.ufpr.br
+export SMTP_ADDRESS=urquell.c3sl.ufpr.br
+export SMTP_PORT=587
 
 ### Gitlab
 export GITLAB_PORTALMEC_PRIVATE_TOKEN=
@@ -57,8 +57,13 @@ export RAILS_ENV=production
 
 ### Puma
 export PORT=3000
-export WEB_CONCURRENCY=$(nproc) # workers
-export RAILS_MAX_THREADS=6 # threads per worker
+#export WEB_CONCURRENCY=$(nproc) # workers
+export WEB_CONCURRENCY=8 # workers
+export RAILS_MAX_THREADS=8 # threads per worker
 
 ### Redis
 export REDIS_HOST=localhost:6379
+
+### Google
+export GOOGLE_KEY=288460085642-k4veg4fo8kddvjer8b055n9da5qtgha7.apps.googleusercontent.com
+export GOOGLE_SECRET=C3OFletrmEU3lcY8YOHtnr7z
diff --git a/config/initializers/elasticsearch.rb b/config/initializers/elasticsearch.rb
index 52ebee06a1d3a27f7ebc3fef434fe22871ebe56b..ca3584792cfacb999d94abb60f7ea67821d2b6d9 100644
--- a/config/initializers/elasticsearch.rb
+++ b/config/initializers/elasticsearch.rb
@@ -26,10 +26,10 @@ if Rails.env.production?
     transport_options: {
       request: {
         timeout: 550
-      },
-      headers: {
-        Authorization: "Basic " + Base64.strict_encode64(login + ":" + pass)
-      }
+      }#,
+      #headers: {
+      #  Authorization: "Basic " + Base64.strict_encode64(login + ":" + pass)
+      #}
     }
   )
 elsif Rails.env.test?
@@ -45,3 +45,5 @@ else
 end
 
 Searchkick.client = elasticsearch_client
+#Searchkick.redis = ConnectionPool.new { Redis.new } 
+#Searchkick::ProcessQueueJob.perform_later(class_name: "LearningObject")
diff --git a/config/routes.rb b/config/routes.rb
index c12a8216f2e7c68cb01ba1cff7eeb3e5ad0e693d..a58747c8ab92da4bc47d19503dd073837e9ec5c2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -244,5 +244,8 @@ Rails.application.routes.draw do
     get '/subjects', to: 'subjects#index'
     get '/educational_stages', to: 'educational_stages#index'
     get 'learning_objects/magnetlink/:magnetlink', to: 'learning_objects#magnetlink', as: 'magnetlink_learning_objects'
+    get 'submissions/user_submissions/:user_id', to: 'submissions#user_submissions'
+    get 'submissions/all_users_submissions/:user_id', to: 'submissions#all_users_submissions'
+    get 'learning_objects_complaints/queue_user/:user_id', to: 'learning_objects_complaints#queue_user'
   end
 end
diff --git a/config/secrets.yml b/config/secrets.yml
index 54ab27ce6c449cecfb67120037f739aac1c38cda..0581df59ad70bc1f8652f6ffa39913195be5661d 100644
--- a/config/secrets.yml
+++ b/config/secrets.yml
@@ -38,5 +38,5 @@ test:
 # Do not keep production secrets in the repository,
 # instead read values from the environment.
 production:
-  secret_token: '<%= ENV["SECRET_TOKEN"] %>'
-  secret_key_base: '<%= ENV["SECRET_KEY_BASE"] %>'
+  secret_token: 96d4039aa1f2e9b11cc875a361afc429943f3db44cb31f6b9f6b43db314ba8dc0c7cb0123a1c7dc119f48290aeefd49225ce3dab82aaa3361face59fd0b872ab
+  secret_key_base: 88636022c8af91192474b5c6b0f8334d63261a83a36b564918884b7bb1461b5e82e1d295f9a0014b85b3a82cdaf522e26fe105b9bc81d74ee7277d084594f68f
diff --git a/db/migrate/20220921123353_add_deleted_at_to_complaint_votes.rb b/db/migrate/20220921123353_add_deleted_at_to_complaint_votes.rb
new file mode 100644
index 0000000000000000000000000000000000000000..6780dc594fa1feed3644d297747d11e481a077a1
--- /dev/null
+++ b/db/migrate/20220921123353_add_deleted_at_to_complaint_votes.rb
@@ -0,0 +1,6 @@
+class AddDeletedAtToComplaintVotes < ActiveRecord::Migration[7.0]
+  def change
+    add_column :complaint_votes, :deleted_at, :datetime
+    add_index :complaint_votes, :deleted_at
+  end
+end
diff --git a/db/migrate/20220921134130_add_user_id_to_complaint_votes.rb b/db/migrate/20220921134130_add_user_id_to_complaint_votes.rb
new file mode 100644
index 0000000000000000000000000000000000000000..e1de3ec4425fc16f3d35e2e253ff00d32aa1b168
--- /dev/null
+++ b/db/migrate/20220921134130_add_user_id_to_complaint_votes.rb
@@ -0,0 +1,10 @@
+class AddUserIdToComplaintVotes < ActiveRecord::Migration[7.0]
+  def change
+
+    add_column :complaint_votes, :user_id, :integer
+    add_foreign_key :complaint_votes, :users
+    add_index :complaint_votes, [:user_id, :complainable_id, :complainable_type], unique: true, name: 'user_and_complainable'
+
+  end
+end
+
diff --git a/db/seeds/complaints.rb b/db/seeds/complaints.rb
index 0fca5079f3f9baf86f7047eaaab18d7cda40138f..52126af608b7f6810dedad2cd3373c1887cd4802 100644
--- a/db/seeds/complaints.rb
+++ b/db/seeds/complaints.rb
@@ -17,9 +17,9 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
 
-ComplaintReason.create(reason: "Objeto viola direitos autorais")
-ComplaintReason.create(reason: "Comtém conteúdo ofensivo/abusivo")
-ComplaintReason.create(reason: "Esta é uma conta falsa")
-ComplaintReason.create(reason: "Isso é um spam")
-ComplaintReason.create(reason: "A descrição não corresponde ao seu conteúdo")
-ComplaintReason.create(reason: "Esta pesssoa está fingindo ser eu ou alguém que eu conheço")
+ComplaintReason.create(reason: "Objeto viola direitos autorais", priority: 4)
+ComplaintReason.create(reason: "Contém conteúdo ofensivo/abusivo", priority: 5)
+ComplaintReason.create(reason: "Esta é uma conta falsa", priority: 3)
+ComplaintReason.create(reason: "Isso é um spam", priority: 1)
+ComplaintReason.create(reason: "A descrição não corresponde ao seu conteúdo", priority: 2)
+ComplaintReason.create(reason: "Esta pesssoa está fingindo ser eu ou alguém que eu conheço", priority: 3)
diff --git a/lib/tasks/access.rake b/lib/tasks/access.rake
index be9ca3a72e2dd14116cfac5cee571ffb1ede7bfb..3bd5d2862835615ea9d5183b0e54292d125c757a 100644
--- a/lib/tasks/access.rake
+++ b/lib/tasks/access.rake
@@ -1,6 +1,6 @@
 namespace :access do
     desc 'Check when all users was created, and give access to them if they were created before a certain date'
-    base_date = Date.new(2022, 7, 20)
+    base_date = Date.new(2025, 12, 12)
     
     task :confirm_old_emails => :environment do
         User.all.each do |user|
@@ -11,4 +11,4 @@ namespace :access do
 
         end
     end
-end
\ No newline at end of file
+end
diff --git a/lib/tasks/change_priority_old_complaints.rake b/lib/tasks/change_priority_old_complaints.rake
new file mode 100644
index 0000000000000000000000000000000000000000..9a1d1f9cb3eabcffdf55e24f7e70b99181c24436
--- /dev/null
+++ b/lib/tasks/change_priority_old_complaints.rake
@@ -0,0 +1,13 @@
+namespace :change_priority_old_complaints do
+    desc 'Change the priority of old complaints to 25'
+    base_date = Date.new(2022, 3, 20)
+
+    task :change_priority => :environment do
+        Complaint.all.each do |complaint|
+            if (complaint.created_at < base_date)
+                complaint.update_attribute(:complaint_reason_id, 7)
+            end
+        end
+    end
+
+end
\ No newline at end of file
diff --git a/lib/tasks/change_state.rake b/lib/tasks/change_state.rake
new file mode 100644
index 0000000000000000000000000000000000000000..fa6ed3d6483c39f563c8008e2240f332a7cc12f3
--- /dev/null
+++ b/lib/tasks/change_state.rake
@@ -0,0 +1,13 @@
+namespace :change_state do
+    desc 'Check when all lo in Complaints, and change the state to 2 if they count is greater than 2'
+    base_date = Date.new(2022, 3, 20)
+
+    task :change_state_lo => :environment do
+        Complaint.all.each do |complaint|
+            if (Complaint.where(complainable_id: complaint.complainable_id).count >= 2 || complaint.created_at < base_date)
+                LearningObject.where(id: complaint.complainable_id).update_all(state: LearningObject.states[:suspended])
+            end
+        end
+    end
+
+end
\ No newline at end of file
diff --git a/lib/tasks/update_state_complainable_lo.rake b/lib/tasks/update_state_complainable_lo.rake
new file mode 100644
index 0000000000000000000000000000000000000000..c0494e506740c18486f3e6dec6cf8532e33d433f
--- /dev/null
+++ b/lib/tasks/update_state_complainable_lo.rake
@@ -0,0 +1,18 @@
+namespace :update_state_complainable_lo do
+    desc 'Update state of complainable learning objects'   
+    base_date = Date.new(2022, 7, 20)
+
+    task :update_lo => :environment do
+        Complaint.all.each do |complaint|
+            if (complaint.created_at < base_date)
+                # update the state of learning object to 0 (complained)
+                # check first if the lo exist
+                lo = LearningObject.where(id: complaint.complainable_id)
+                if (lo != nil)
+                    LearningObject.where(id: complaint.complainable_id).update(state: 2)    
+                end
+            end
+        end
+    
+    end
+end
\ No newline at end of file
diff --git a/public/attachments/16179/Dorwin_BL2.zip b/public/attachments/16179/Dorwin_BL2.zip
new file mode 100644
index 0000000000000000000000000000000000000000..9628a1431da2d94f9594d1a1b3e081e078be6f34
Binary files /dev/null and b/public/attachments/16179/Dorwin_BL2.zip differ
diff --git a/public/attachments/17505/Darwin_BL1.zip b/public/attachments/17505/Darwin_BL1.zip
new file mode 100644
index 0000000000000000000000000000000000000000..d00d054e00bf11af0c327939d047436eb5d11412
Binary files /dev/null and b/public/attachments/17505/Darwin_BL1.zip differ
diff --git a/public/attachments/23892/DOMINIO_EM_HIS_0146.wmv b/public/attachments/23892/DOMINIO_EM_HIS_0146.wmv
new file mode 100644
index 0000000000000000000000000000000000000000..26011a8d6bba99e22edcc7bb04374eb8a8a57bd9
Binary files /dev/null and b/public/attachments/23892/DOMINIO_EM_HIS_0146.wmv differ
diff --git a/public/attachments/23893/DOMINIO_EM_HIS_0146.mp4 b/public/attachments/23893/DOMINIO_EM_HIS_0146.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..2a4db961927582f681b1fdbb9840b4da65dcefbe
Binary files /dev/null and b/public/attachments/23893/DOMINIO_EM_HIS_0146.mp4 differ
diff --git a/public/attachments/27305/1421.torrent b/public/attachments/27305/1421.torrent
new file mode 100644
index 0000000000000000000000000000000000000000..78b72cecebb632170bde5551186d67d3dd75acdb
Binary files /dev/null and b/public/attachments/27305/1421.torrent differ
diff --git a/public/attachments/39961/15788.torrent b/public/attachments/39961/15788.torrent
new file mode 100644
index 0000000000000000000000000000000000000000..58010593cd2db332cf8ecc3a4925936db3a9ede5
--- /dev/null
+++ b/public/attachments/39961/15788.torrent
@@ -0,0 +1 @@
+<!doctype html><html lang="en"><head><title>HTTP Status 500 – Internal Server Error</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 500 – Internal Server Error</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Internal Server Error</p><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p><hr class="line" /><h3>Apache Tomcat/8.5.50 (Debian)</h3></body></html>
\ No newline at end of file
diff --git a/public/attachments/42061/19284.torrent b/public/attachments/42061/19284.torrent
new file mode 100644
index 0000000000000000000000000000000000000000..6570453075e51cd906d6a16694c364a584e1deab
Binary files /dev/null and b/public/attachments/42061/19284.torrent differ
diff --git a/public/attachments/44357/21974.torrent b/public/attachments/44357/21974.torrent
new file mode 100644
index 0000000000000000000000000000000000000000..491468f4e4e64753878cf6e0dbd883e6f9d842df
Binary files /dev/null and b/public/attachments/44357/21974.torrent differ
diff --git a/public/attachments/815/Construtores_-_Getulio_Vargas.avi b/public/attachments/815/Construtores_-_Getulio_Vargas.avi
new file mode 100644
index 0000000000000000000000000000000000000000..1760a72659f2bf1be372d75ec5d78aae9d9732f2
Binary files /dev/null and b/public/attachments/815/Construtores_-_Getulio_Vargas.avi differ
diff --git a/public/packages/020c4189ae59ad14acd33009.zip b/public/packages/020c4189ae59ad14acd33009.zip
new file mode 100644
index 0000000000000000000000000000000000000000..15cb0ecb3e219d1701294bfdf0fe3f5cb5d208e7
Binary files /dev/null and b/public/packages/020c4189ae59ad14acd33009.zip differ
diff --git a/public/packages/7807a34ad6716436c8aaad70.zip b/public/packages/7807a34ad6716436c8aaad70.zip
new file mode 100644
index 0000000000000000000000000000000000000000..15cb0ecb3e219d1701294bfdf0fe3f5cb5d208e7
Binary files /dev/null and b/public/packages/7807a34ad6716436c8aaad70.zip differ
diff --git a/public/packages/a4797832e60a51bafc3d1649.zip b/public/packages/a4797832e60a51bafc3d1649.zip
new file mode 100644
index 0000000000000000000000000000000000000000..15cb0ecb3e219d1701294bfdf0fe3f5cb5d208e7
Binary files /dev/null and b/public/packages/a4797832e60a51bafc3d1649.zip differ
diff --git a/public/packages/b17311d42455ec40ced445b4.zip b/public/packages/b17311d42455ec40ced445b4.zip
new file mode 100644
index 0000000000000000000000000000000000000000..368d1506b48cf3e32d3a3bd3514391d2956044c8
Binary files /dev/null and b/public/packages/b17311d42455ec40ced445b4.zip differ
diff --git a/public/packages/b46308de62f04b8f26dcd4fa.zip b/public/packages/b46308de62f04b8f26dcd4fa.zip
new file mode 100644
index 0000000000000000000000000000000000000000..141b5fb74f7af36b0614da86b29f6b2035524e45
Binary files /dev/null and b/public/packages/b46308de62f04b8f26dcd4fa.zip differ
diff --git a/public/packages/e7b7b7514f0511057033a8f9.zip b/public/packages/e7b7b7514f0511057033a8f9.zip
new file mode 100644
index 0000000000000000000000000000000000000000..d2edaa53201eb56afd416d8e16361b72cc9c1702
Binary files /dev/null and b/public/packages/e7b7b7514f0511057033a8f9.zip differ
diff --git a/public/packages/ec6842374053676f0039da44.zip b/public/packages/ec6842374053676f0039da44.zip
new file mode 100644
index 0000000000000000000000000000000000000000..73be0cd35e1a8cfb90ff044fa8a1709a8e49b80d
Binary files /dev/null and b/public/packages/ec6842374053676f0039da44.zip differ
diff --git a/puma.sh b/puma.sh
old mode 100644
new mode 100755
index a84c29d7235f8f9f7a51edd316e17d422b390b0d..1ea6eb158e166cf671c45f9ed02dad51143760ca
--- a/puma.sh
+++ b/puma.sh
@@ -18,9 +18,9 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
 
-source /home/.rvm/scripts/rvm
+source /home/portalmec/.rvm/scripts/rvm
 
-export PUMA_APP_DIR=/portalmec
+export PUMA_APP_DIR=/home/portalmec/portalmec-update/cleanning-portalmec
 
 source $PUMA_APP_DIR/config/env_vars.sh 2>/dev/null
 
@@ -28,10 +28,10 @@ option="${1}"
 
 case ${option} in
    start)
-      source start_puma.sh
+      source $PUMA_APP_DIR/start_puma.sh
       ;;
    stop)
-      source stop_puma.sh
+      source $PUMA_APP_DIR/stop_puma.sh
       ;;
    *)
       echo "`basename ${0}`:usage: [start] | [stop]"
diff --git a/start_puma.sh b/start_puma.sh
old mode 100644
new mode 100755
index 3cbfc0cfa935311bc9d5bb2bfb78fad8e60022aa..26f18d9f1eb16ba631557ef672022839c6b2e53d
--- a/start_puma.sh
+++ b/start_puma.sh
@@ -19,6 +19,7 @@
 # along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
 
 source $PUMA_APP_DIR/config/env_vars.sh
+source /home/portalmec/.rvm/scripts/rvm
 
 cd $PUMA_APP_DIR
 #rake assets:precompile
diff --git a/stop_puma.sh b/stop_puma.sh
old mode 100644
new mode 100755