Skip to content
Snippets Groups Projects
Commit 0eba5929 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Changed curator activities and feed

parent 8970c773
No related branches found
No related tags found
No related merge requests found
......@@ -33,26 +33,29 @@ class V1::FeedController < ApplicationController
private
def activities_followed
query = "privacy = 'public' and ("
query = ""
values = [""]
# builds a query string to find all relevant activities
current_user.watching.each do |watching|
if !watching.respond_to?(:state) || watching.state == "published"
query += " ((trackable_type = ? and trackable_id = ?) or (owner_type = ? and owner_id = ?) or (recipient_type = ? and recipient_id = ?) "
unless (watching.class == Submission || watching.class == CuratorAssignment) && watching.try(:activity_owner) == current_user
query += "and privacy = 'public'"
end
query += ") or"
# Activities that are made by, owned by, or change the object you follow should be found
query += " (trackable_type = ? and trackable_id = ?) or (owner_type = ? and owner_id = ?) or (recipient_type = ? and recipient_id = ?) or"
3.times do
values << watching.class.to_s
values << watching.id
end
end
end
if query[-1] == "("
query = query[0..-6]
else
values[0] = query[0..-3]+")" # remove trailing "or" on the query
if query[-1] == "r"
query = query[0..-3] # remove trailing "or" on the query
end
return PublicActivity::Activity.where(key: activities_filter).where(values).order(created_at: :desc)
end
......
......@@ -28,8 +28,6 @@ module Trackable
after_update :new_update_activity
end
private
def new_update_activity
return nil if changed.blank?
return new_activity(:update) if ignore_changes == %w(updated_at)
......
......@@ -30,7 +30,7 @@
class CuratorAssignment < ApplicationRecord
include Trackable
enum status: [:assigned, :answered, :ignored]
belongs_to :submission
......@@ -43,6 +43,6 @@ class CuratorAssignment < ApplicationRecord
end
def activity_recipient
submission
submission.learning_object
end
end
......@@ -59,7 +59,7 @@ class Submission < ApplicationRecord
status = answers.all? { |a| a.accepted? } ? :accepted : :rejected
self.update_columns(status: status, answered_at: Time.current)
new_activity(:update, {status: self.status})
new_activity(self.status)
end
end
......
......@@ -139,7 +139,7 @@ class User < ApplicationRecord
end
def delete_index
User.searchkick_index.remove(self)
User.searchkick_index.remove(self)
end
def is_admin?
......@@ -294,7 +294,7 @@ class User < ApplicationRecord
# ~~~~ end followable actions ~~~~ #
def default_role
roles << Role.teacher
roles << Role.submitter
end
def self.from_omniauth(access_token)
......@@ -357,7 +357,7 @@ class User < ApplicationRecord
if option == "blocked"
self.suspended_at = Time.current
self.reactivated_at = self.suspended_at + 7.day
self.increment(:times_blocked, 1)
self.increment(:times_blocked, 1)
self.blocked!
elsif option == "banished"
self.suspended_at = Time.current
......
......@@ -33,8 +33,8 @@ module ActivitiesFilterService
[ 'complaint.create',
'collection.create', 'collection.update', 'collection.destroy',
'collection_item.create', 'collection_item.update', 'collection_item.destroy',
'learning_object.create', 'learning_object.destroy',
'submission.update',
'learning_object.publish', 'learning_object.destroy',
'submission.accepted', 'submission.rejected',
'curator_assignment.create',
'review.create',
'download.create',
......
......@@ -57,6 +57,7 @@ class LearningObjectPublisher
end
# ThumbnailGenerateWorker.perform_async learning_object.id, learning_object.link if learning_object.link?
learning_object.save
learning_object.new_activity(:publish)
end
def update_dspace(object)
......
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