Skip to content

Instantly share code, notes, and snippets.

@IlyaDonskikh
IlyaDonskikh / Iskra_sync
Created September 17, 2014 03:16
Iskra_sync
def sync_1c
if !Rails.env.test?
client = Savon.client(wsdl: Iskra::Application::ADDRESS_1C, env_namespace: :soap, namespace_identifier: :m, convert_request_keys_to: :camelcase)
@user = case type
when 'DeleteSeminarParticipantRequest', 'DeleteSeminarParticipant', 'AddSeminarParticipant' then self.person_id
else
user_id.nil? ? '' : self.user_id
end
RtQuota Load (0.2ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 9 OR rt_quota_id = 9) LIMIT 1
RtQuota Load (0.1ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 1 OR rt_quota_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 9 OR rt_quota_id = 9) LIMIT 1
CACHE (0.0ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 1 OR rt_quota_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 9 OR rt_quota_id = 9) LIMIT 1
CACHE (0.0ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 1 OR rt_quota_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 9 OR rt_quota_id = 9) LIMIT 1
CACHE (0.0ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 1 OR rt_quota_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 9 OR rt_quota_id = 9) LIMIT 1
CACHE (0.0ms) SELECT "rt_quota".* FROM "rt_quota" WHERE (quota_id = 1 OR rt_quota_id = 1) LIMIT 1
AND "quota"."quotable_type" = 'Flight' LEFT OUTER JOIN "modifiers" ON "modifiers"."quota_id" = "quota"."id" LEFT OUTER JOIN "blocked_quota" ON "blocked_quota"."quota_id" = "quota"."id" WHERE (flights.public_status = 't' AND intervals.start_date <= '2014-11-22' AND intervals.end_date >= '2014-11-07')
RtQuota Load (0.2ms) SELECT "rt_quota".* FROM "rt_quota" WHERE "rt_quota"."quota_id" = ? LIMIT 1 [["quota_id", 9]]
RtQuota Load (0.2ms) SELECT "rt_quota".* FROM "rt_quota" WHERE "rt_quota"."rt_quota_id" = ? LIMIT 1 [["rt_quota_id", 9]]
RtQuota Load (0.1ms) SELECT "rt_quota".* FROM "rt_quota" WHERE "rt_quota"."quota_id" = ? LIMIT 1 [["quota_id", 1]]
RtQuota Load (0.1ms) SELECT "rt_quota".* FROM "rt_quota" WHERE "rt_quota"."rt_quota_id" = ? LIMIT 1 [["rt_quota_id", 1]]
Airline Load (0.2ms) SELECT "airlines".* FROM "airlines" WHERE "airlines"."id" = ? LIMIT 1 [["id", 1]]
Rendered flights/search/_item.html.erb (16.5ms)
Rendered flights/search/_item.html.erb (2.7ms)
Rendered flights/search/_it
---
:dep_city:
"Москва": '2671'
"Архангельск": '2349'
"Барнаул": '2370'
"Белгород": '2373'
"Владивосток": '2984'
"Волгоград": '2989'
"Воронеж": '2999'
"Екатеринбург": '2449'
sql = 'SELECT ctr.id, ctr.code as country_code, ctr.name as country_name, c.id, c.country_id,
c.code as city_code, c.name as city_name, a.code as airport_code, a.name as airport_name, a.city_id
FROM countries AS ctr INNER JOIN cities AS c INNER JOIN airports AS a
WHERE ctr.id = c.country_id AND a.city_id = c.id AND (ctr.name = ? OR ctr.code = ? OR c.name = ? OR c.code = ? OR a.code = ? OR a.name = ?)'
sql = ActiveRecord::Base.send(:sanitize_sql_array, [sql, name.upcase, name, name.upcase, name, name.upcase, name])
result_hash = ActiveRecord::Base.connection.execute(sql)
## Old sql query (same error)
sql = 'SELECT ctr.id, ctr.code as country_code, ctr.name as country_name, c.id, c.country_id,
c.code as city_code, c.name as city_name, a.code as airport_code, a.name as airport_name, a.city_id
sql = 'SELECT ctr.id, ctr.code as country_code, ctr.name as country_name, c.id, c.country_id,
c.code as city_code, c.name as city_name, a.code as airport_code, a.name as airport_name, a.city_id
FROM countries AS ctr INNER JOIN cities AS c INNER JOIN airports AS a
ON (ctr.name = ? OR ctr.code = ? OR c.name = ? OR c.code = ? OR a.code = ? OR a.name = ?)
AND ctr.id = c.country_id AND a.city_id = c.id'
sql = ActiveRecord::Base.send(:sanitize_sql_array, [sql, name.upcase, name, name.upcase, name, name.upcase, name])
result_hash = ActiveRecord::Base.connection.execute(sql)
## Result (development)
SELECT ctr.id, ctr.code as country_code, ctr.name as country_name, c.id, c.country_id,
@IlyaDonskikh
IlyaDonskikh / flight_search.rb
Last active August 29, 2015 14:15
Flight search
class FlightSearch
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :departure, :arrival, :date, :quotas, :return_quotas, :business_class, :with_return, :return_date,
:errors, :all_flights, :all_rt_flights, :adults, :childrens, :infants
## Validates
validates :departure, :arrival, :date, presence: true
class CardPayment < ActiveRecord::Base
include InterpolateModule
attr_accessor :refund_value
## Relations
belongs_to :money_operation
has_one :order, through: :money_operation
## Variables
OPERATIONS = %w(payment refund)
case query_privacy
when 0
feeds = get_global_feed
when 1
feeds = get_friends_feed
when 2
feeds = get_private_feed
else
end
# проверка app-token только для :signin,:signUp
before_action :set_app_profile, only: [:signin, :signup, :merchant_lead_register]
## Че правда?