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
module Preloading | |
def preload(records, association_name, preload_scope) | |
return records if records.blank? | |
reflection = records.first.association(association_name).reflection | |
if reflection.through_reflection | |
grouped_scope = reflection.through_reflection.klass.where(reflection.foreign_key => preload_scope). | |
includes(reflection.source_reflection_name). | |
each_with_object({}) do |r, hash| |
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 register_user_account(order) | |
order.transaction do | |
account = order.register_account(guest_header) | |
Account::InitializeAccount.call(account: account) | |
account | |
end | |
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
(ns scylla-bench.core | |
(:require [clojurewerkz.cassaforte.client :as client] | |
[clojurewerkz.cassaforte.cql :as cql] | |
[clojurewerkz.cassaforte.query :as dsl])) | |
(def STEP-SIZE 1000) | |
(def counter (agent [nil, 0])) | |
(defn connect [] | |
(client/connect |
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
-module(listsum). | |
-export([add_two_numbers/2]). | |
add_two_numbers(L1, L2) -> | |
lists:reverse(add_two_lists(L1, L2, 0, [])). | |
add_two_lists([], [], 0, Acc) -> | |
Acc; | |
add_two_lists([], [], Over, Acc) -> | |
[Over|Acc]; |