* Prepare: relocate user suggestions * Prepare: relocate users suggestion service -> query * Organization query for orgs with above-average scores * Rubocop * Limit to last 3 weeks * Tweak recent scope, limit to 5 orgs * Onboarding routes are also always JSON * Divide by zero makes NaN means * Add Orgs suggester into suggestions * Rubocop * select distinct orgs * Fix for weird edge-case with bad local data * Include type_identifier in JSON payload * Update follows API to allow org_ids as input * Update onboarding front-end to distinguish users/orgs * Fix: i18n issues * Fix: type_identifier in json output * Fix: distinct is weird * Fix: JS linter * Continue tweaking front-end * Audit import order * Cleanup @todo note * Try renaming controller action * Move Article average calculation to postgres and fix math * Refactor decorated type_identifier * Refactor SuggestProminent, return more orgs, fix spec math * Use FeatureFlag for organization suggestions * This might fix the jest
41 lines
968 B
Ruby
41 lines
968 B
Ruby
module Api
|
|
module FollowsController
|
|
extend ActiveSupport::Concern
|
|
|
|
def create
|
|
user_ids.each do |user_id|
|
|
Users::FollowWorker.perform_async(current_user.id, user_id, "User")
|
|
end
|
|
|
|
org_ids.each do |org_id|
|
|
Users::FollowWorker.perform_async(current_user.id, org_id, "Organization")
|
|
end
|
|
|
|
render json: {
|
|
outcome: I18n.t("api.v0.follows_controller.followed",
|
|
count: user_ids.size + org_ids.size)
|
|
}
|
|
end
|
|
|
|
def tags
|
|
@follows = @user.follows_by_type("ActsAsTaggableOn::Tag")
|
|
.select(%i[id followable_id followable_type points])
|
|
.includes(:followable)
|
|
.order(points: :desc)
|
|
end
|
|
|
|
private
|
|
|
|
def user_ids
|
|
return [] if params[:users].blank?
|
|
|
|
@user_ids ||= params[:users].pluck("id")
|
|
end
|
|
|
|
def org_ids
|
|
return [] if params[:organizations].blank?
|
|
|
|
@org_ids ||= params[:organizations].pluck("id")
|
|
end
|
|
end
|
|
end
|