Skip to content

Instantly share code, notes, and snippets.

View varpa89's full-sized avatar

Pavel Varchenko varpa89

View GitHub Profile
childDeepClone: function (child) {
var childCopy = _.pick(child, 'lastName', 'firstName', 'middleName', 'birthDate', 'gender', 'birthPlace', 'snils');
if (_.isArray(child.addressList)) {
var addressCopy = [];
_.each(child.addressList, function (address) {
if (address) {
addressCopy.push(_.pick(address, 'postalCode', 'fullAddress', 'fullHouse', 'addressUID', 'houseUID', 'plain', 'oktmo', 'flat', 'type'));
} else {
addressCopy.push(null);
}
explain ANALYZE WITH RECURSIVE sub_orgs(gid, organization_type) AS
(SELECT o.gid, o.organization_type FROM en_organization o
WHERE gid = 'b55d19bc-1ecc-68d9-bf7a-78ec21808327'
UNION SELECT
o.gid, o.organization_type FROM sub_orgs so, en_organization o
WHERE o.management_organization_gid = so.gid AND o.organization_type IN ('MOUO', 'ROUO'))
SELECT * FROM sub_orgs;
"CTE Scan on sub_orgs (cost=16.32..17.14 rows=41 width=36)"
" CTE sub_orgs"
@varpa89
varpa89 / new
Created October 29, 2014 08:11
WITH RECURSIVE oktmos ("id", parent_id) AS (
SELECT o."id", o.parent_id
FROM oktmo o
WHERE o."id" = 71875000
UNION ALL
SELECT o."id", o.parent_id
FROM oktmo o INNER JOIN oktmos ON (oktmos."id" = o.parent_id)
),
fs AS (
SELECT sc."id", sc."shortname"
@varpa89
varpa89 / old
Created October 29, 2014 08:10
WITH RECURSIVE oktmos ("id", parent_id) AS (
SELECT o."id", o.parent_id
FROM oktmo o
WHERE o."id" = 71875000
UNION ALL
SELECT o."id", o.parent_id
FROM oktmo o INNER JOIN oktmos ON (oktmos."id" = o.parent_id)
),
schools_in_municipality AS (
SELECT sc."id", sc."shortname"