Skip to content

Commit 3f70945

Browse files
committed
css
1 parent 2d2409b commit 3f70945

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

server.js

+50-4
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,58 @@ const session = driver.session();
153153

154154

155155
let schema = [
156+
//PROFILE
157+
`WITH [] AS area, [
158+
'POLYGON((37.036529609374995 56.03991134977714,38.220306464843716 56.03991134977714,38.220306464843716 55.404346266130695,37.036529609374995 55.404346266130695,37.036529609374995 56.03991134977714))',
159+
'POLYGON((37.036529609374995 56.03991134977714,38.220306464843716 56.03991134977714,38.220306464843716 55.404346266130695,37.036529609374995 55.404346266130695,37.036529609374995 56.03991134977714))'
160+
] AS poly
161+
UNWIND poly AS p
162+
CALL custom.polygon5(p) YIELD buildings
163+
WITH area + COLLECT(DISTINCT buildings) AS area
164+
165+
CALL custom.polygon5('POLYGON((37.036529609374995 56.03991134977714,38.220306464843716 56.03991134977714,38.220306464843716 55.404346266130695,37.036529609374995 55.404346266130695,37.036529609374995 56.03991134977714))') YIELD buildings
166+
WITH area, COLLECT(DISTINCT buildings) AS viewport
167+
168+
WITH apoc.coll.intersection(viewport, area) AS intersect
169+
170+
CALL apoc.nodes.get(intersect) YIELD node AS building
171+
WITH intersect, building LIMIT 2000 WHERE building.operation_year < 2023
172+
173+
MATCH (building)<--(l :Лот)-[:тип]->(nt:\`Тип недвижимости\`)
174+
WHERE
175+
l.price > 5000000 AND l.price < 10000000
176+
AND l.square > 10 AND l.square < 100
177+
WITH DISTINCT building LIMIT 20
178+
179+
MATCH (building)<--(l :Лот)-[:тип]->(nt:\`Тип недвижимости\`)
180+
WHERE
181+
l.price > 5000000 AND l.price < 10000000
182+
AND l.square > 10 AND l.square < 100
183+
184+
WITH building {.*, lots: {type: nt.name, rooms: l.rooms, count: COUNT(l), price: { min: MIN(l.price), max: MAX(l.price) }, square: { min: MIN(l.square), max: MAX(l.square)} } } //SKIP 80 LIMIT 20
185+
186+
//WITH SIZE(intersect) AS area
187+
188+
RETURN *`,
156189
'CREATE INDEX ON :Адрес(name)',
157190
'CREATE INDEX ON :Девелопер(name)',
158191
'CREATE INDEX ON :Застройщик(name)',
159192
'CREATE INDEX ON :Класс(name)',
160193
'CREATE INDEX ON :Конструктив(name)',
161194
'CREATE INDEX ON :Корпус(id)',
195+
'CREATE INDEX ON :Корпус(operation_year)',
196+
'CREATE INDEX ON :Корпус(operation_quarter)',
162197
'CREATE INDEX ON :Лот(id)',
163198
'CREATE INDEX ON :Лот(price)',
199+
'CREATE INDEX ON :Лот(square)',
164200
'CREATE INDEX ON :Отделка(name)',
165201
'CREATE INDEX ON :Проект(name)',
166202
'CREATE INDEX ON :Стадия(name)',
167203
'CREATE INDEX ON :`Тип парковки`(name)',
168204
'CREATE INDEX ON :`Тип недвижимости`(name)',
169205
'CREATE INDEX ON :`Тип фото`(name)',
170206
'CREATE INDEX ON :Фото(url)',
171-
//'CALL spatial.removeLayer("geom")',
207+
'CALL spatial.removeLayer("geom")',
172208
'CALL spatial.addPointLayer("geom")'
173209
]
174210

@@ -189,7 +225,13 @@ promise.then(async result => {
189225
session.close();
190226

191227
for(let i = 0; i < schema.length; i++) {
192-
await session.run(schema[i]);
228+
try {
229+
console.time('try');
230+
await session.run(schema[i]);
231+
console.timeEnd('try');
232+
console.log(schema[i]);
233+
}
234+
catch(err) {}
193235
}
194236

195237
const singleRecord = result.records[0];
@@ -210,7 +252,7 @@ promise.then(async result => {
210252
await Promise.all(queries);
211253
queries = [];
212254

213-
let part = ids.splice(0, 20);
255+
let part = ids.splice(0, 10);
214256
let i = part.length - 1;
215257

216258

@@ -230,12 +272,16 @@ promise.then(async result => {
230272
})
231273
.then(result => {
232274
let building = result.data;
275+
//building.id = building.id + '';
233276

234277
const session = driver.session();
235278
const promise = session.run(
236279
`WITH {building} as building
237280
238-
MERGE (b :Корпус {id: building.id}) SET b += building {.commercial_square, .total_square, .pantry_count, .created_at, .floors_num, .parking_spaces_count, .discounts, .updated_at, .parking_available, .floors_from, .pantry_available, .construction_start, .floors_to, .in_operation_date, .sales_start, .name, .living_square, .ceiling_height, .building_type}
281+
MERGE (b :Корпус {id: building.id}) SET b += building {.commercial_square, .total_square, .pantry_count, .created_at, .floors_num,
282+
.parking_spaces_count, .discounts, .updated_at, .parking_available, .floors_from, .pantry_available, .construction_start,
283+
.floors_to, .in_operation_date, .sales_start, .name, .living_square, .ceiling_height, .building_type,
284+
operation_year: date(building.in_operation_date).year, operation_quarter: date(building.in_operation_date).quarter}
239285
240286
MERGE (cs :Стадия {name: COALESCE(building.construction_stage.name, 'Не указано')}) SET cs += COALESCE(building.construction_stage, {})
241287
MERGE (pt :\`Тип парковки\` {name: COALESCE(building.parking_type.name, 'Не указано')}) SET pt += COALESCE(building.parking_type, {})

0 commit comments

Comments
 (0)