Skip to content

Instantly share code, notes, and snippets.

View fmundaca's full-sized avatar

Felipe Mundaca fmundaca

View GitHub Profile
namespace :db do
namespace :migrate do
task tenant: :environment do
tenant_name = ENV["TENANT"]
origin_org_slug = ENV["ORIGIN_ORG_SLUG"]
destination_org_slug = ENV["DESTINATION_ORG_SLUG"]
tenant = Tenant.find_by(name: tenant_name)
base_organization = Organization.find_by(slug: origin_org_slug)
module Concerns::Publishable
extend ActiveSupport::Concern
included do
if Rails.env.production?
after_commit :pubsub_create, on: :create
after_update :pubsub_update
after_destroy :pubsub_destroy
end
def pubsub_create
# Creado por: Rankmi
# Fecha: <b>24 enero 2016</b>
# Servicio que crea/actualiza un usuario con los datos básicos.
module ManageCollaborators
class CreateCollaborator < RankmiBaseService
include ::Concerns::ServiceHelper
include ::Concerns::FamilyGoalsAdministrable
attr_accessor :enterprise_area, :area_slug, :user_data, :direct_manager,
:user, :process, :survey, :survey_id, :from_master, :massive
# frozen_string_literal: true
module Sns
module Subscriptions
class Users
include Sidekiq::Worker
include Helpers
sidekiq_options queue: 'critical'
# frozen_string_literal: true
module Administration
module PositionsManagement
class PositionPrint < Blueprinter::Base
view :successed do
identifier :id
fields :name, :code, :token, :parent_id, :description, :children_count
# frozen_string_literal: true
class EnterpriseModulesWorker < BaseWorker
shoryuken_options queue: queue('enterprise-modules'),
body_parser: :json,
auto_delete: false,
retry_intervals: [60, 120, 240]
attr_accessor :sqs_msg, :tenant, :event_message
@fmundaca
fmundaca / user.rb
Created April 16, 2019 16:56
Ayudame
def validate(record)
if !record.email.match(Account::VALID_EMAIL_REGEX)
record.errors[:email] << malformed_field('email', "Email no válido: #{record.email} ")
elsif record.id.nil? # new user
if Account.find_by(email: record.email).present?
record.errors[:email] << malformed_field('email', "Email duplicado: #{record.email}")
# return false
end
else
attr_accessor :is_manager_evaluator, :user_area, :is_manager_evaluator,
:is_performance, :user_area_permissions, :is_admin
def initialize(user_id, process_id, survey_id = nil)
@user_id = user_id
@process_id = process_id
@survey_id = survey_id
end
def perform
#begin @eolivar RKM-2780 07/03/2018
def create_or_update_optionals user, optionals
unless !optionals.present?
optionals = optionals.select { |k, v| (v[:value].nil? && v[:id].present?) || (v[:value].present? && !v[:value].empty?) }
optionals.each do |key, value|
user_optional = UserOptional.where(id: value[:id]).first unless !value[:id].present?
if user_optional.present? && value[:value].nil?
user_optional.destroy