This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def accept_group_terms | |
if current_entity.user? && notification.group_terms? | |
if params[:terms_of_service][:checked] | |
user_group = notification.entity.user_groups.with_user(current_entity).first | |
if user_group | |
user_group.terms_accepted_at = Time.now | |
user_group.save | |
notification.mark_as_read_by(current_entity).save! | |
render_notif | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Wf.new | |
.chain { CloseProject.new(project) } | |
.chain { NotifyProjectClosed(project) } | |
.chain { Log.new(:project_closed, project) } | |
.chain { render json: project } | |
.on_dam { |error_pool| render json: {errors: error_pool}, status: 422 } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In controller | |
result = TaxCalculator.new(order).call | |
if result[:success] | |
render json: { value: result[:value] } | |
else | |
render json: { errors: result[:errors] }, status: 422 | |
end | |
# The service | |
class TaxCalculator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET 'https://cc88d7d5589d309a000.qbox.io/entities/timeline_post/_search?size=100000&pretty' -d '{query: { match_all: {} }, fields: ["_source", "_parent"] }' | |
{ | |
"took" : 4, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 1, | |
"successful" : 1, | |
"failed" : 0 | |
}, | |
"hits" : { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'tire' | |
Tire.configure { logger 'elasticsearch.log', :level => 'debug' } | |
class Document | |
attr_accessor :title, :content | |
include Tire::Model::Persistence | |
include Tire::Model::Search | |
include Tire::Model::Callbacks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Syracuse < Struct.new(:initial, :chiffre, :altitude, :duree_vol, :success) | |
HIGHER_THRESHOLD = 100000000000 | |
def initialize(chiffre) | |
self.initial = self.chiffre = chiffre | |
self.altitude = self.duree_vol = 0 | |
end | |
def next |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_discussion_with_client( author, client, document, message ) | |
email_vars = { | |
:locale => client.locale, | |
:job_ref => document.ref, | |
:message => message, | |
:job_link => render_link(review_clients_project_path(id: document.project_id), client.locale) # I cannot find the route to open a document for review from the client's perspective | |
} | |
base_mail( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_username_as_name_if_empty | |
if self.username && self.username.present? | |
self.name = self.username if self.name && self.name.empty? | |
end | |
end | |
def set_username_as_name_if_empty | |
return if !username.blank? || !name.blank? | |
self.name = username | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserInfo | |
attr_accessor :contact | |
def initialize(contact = nil) | |
self.contact = contact || NullContact.new | |
end | |
def contact_name | |
contact.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------------------- | |
With one object saved, another in memory | |
-------------------------------------------------------------------------------------------- | |
#setup | |
subject.copywriter_languages.create Factory.attributes_for(:copywriter_language, status: "deleted") | |
subject.copywriter_languages.build Factory.attributes_for(:copywriter_language, status: "pending") | |
#Round 1 | |
#checking default scope | |
subject.copywriter_languages.criteria |