This file contains 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
log_path = File.join(File.dirname(__FILE__), 'fix_time.log') | |
puts "Writing log to '#{log_path}'" | |
open(log_path, 'w+') do |f| | |
zone = '+03:00' | |
zone_shift = 3 | |
bug_begin_datetime = DateTime.new(2017, 10, 19, 18, 50, 00) | |
bug_fixed_datetime = DateTime.new(2017, 10, 19, 18, 52, 30) | |
f.puts "Zone shift is #{zone_shift}" |
This file contains 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
SELECT DISTINCT | |
without_to_name.*, | |
people.full_name AS to_name, | |
hrm_employees.id AS to_employee_id | |
FROM ( | |
SELECT DISTINCT | |
crm_orders.id AS order_id, | |
mango_events_summaries.raw->>'entry_id' AS mango_entry_id, | |
mango_events_recordings.raw->>'recording_id' AS mango_recording_id, | |
mango_events_summaries.raw->>'create_time' AS created_at_time, |
This file contains 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
Rails.application.routes.default_url_options[:host] = 'dev.local:3000' | |
include Rails.application.routes.url_helpers | |
log_path = File.join(File.dirname(__FILE__), 'normalize_phones.log') | |
puts "Writing log to '#{log_path}'" | |
def order_url(order) | |
if order.commercial? | |
commercial_order_url(order.commercial_order) |
This file contains 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
Rails.application.routes.default_url_options[:host] = 'dev.local:3000' | |
include Rails.application.routes.url_helpers | |
log_path = File.join(File.dirname(__FILE__), 'normalize_phones.log') | |
puts "Writing log to '#{log_path}'" | |
def order_url(order) | |
if order.commercial? | |
commercial_order_url(order.commercial_order) |
This file contains 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
Resident::StayPeriod.destroy_all | |
CRM::Contract.find_each do |contract| | |
puts '>>----' | |
puts "Creating StayPeriod for contract with resident_id #{contract.resident_id}" | |
result = Resident::StayPeriod.create(resident_id: contract.resident_id, | |
pansion_id: contract.pansion_id, | |
initial_contract_id: contract.id, | |
checkin_date: contract.enter_date, |
This file contains 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
3.times do |n| | |
SocialServiceRecipient.create!({ | |
first_name: "Имя#{n+1}", | |
middle_name: "Отчество#{n+1}", | |
phone: "+7(92#{n+1})1234567", | |
birth: "0#{n+1}.01.1950", | |
social_service_center_id: 2 | |
}) | |
end |
This file contains 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 full_name(recipient) | |
[recipient.middle_name, recipient.first_name, recipient.last_name].compact.join(' ') | |
end | |
SocialServiceRecipient.select(:phone).group(:phone).having('count(phone) > 1').each do |the_same_phones| | |
with_the_same_phone = SocialServiceRecipient.where(phone: the_same_phones.phone) | |
without_calls = with_the_same_phone.where(count_calls: [0, nil]) | |
with_calls = with_the_same_phone.where.not(count_calls: [0, nil]) | |
# если все респонденты обзвонены, то их нельзя удалять |
This file contains 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 AddDiningTypeToResidents < ActiveRecord::Migration | |
def up | |
query = <<-SQL | |
INSERT INTO accounting_dining_types (name, created_at, updated_at) | |
VALUES ('Стандартный', '#{DateTime.current}', '#{DateTime.current}') | |
SQL | |
result = ActiveRecord::Base.connection.insert(query) | |
dining_type_id = result.to_i | |
add_column :residents, :dining_type_id, :integer, null: false, default: dining_type_id |
This file contains 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
let expect = require('chai').expect; | |
require('vm').runInThisContext(require('fs').readFileSync('./solution.js')); | |
describe('#solution', () => { | |
it('1', () => { | |
expect(isTriangle(1, 2, 2)).to.be.true; | |
}); | |
it('2', () => { | |
expect(isTriangle(7, 2, 2)).to.be.false; |
This file contains 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
import React, { Component } from 'react'; | |
class SearchBar extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { term: '' }; | |
} | |
render() { |